-
Notifications
You must be signed in to change notification settings - Fork 10
/
hide-me
executable file
·143 lines (115 loc) · 3.92 KB
/
hide-me
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env python3
####################################################################################
# hide-me - this script will change the mac address to a random one and will pick #
# a random hostname from specified file. #
# Requirements: macchanger' needs to be installed #
# and command: 'hostname' should be available!!! #
# Written by: Andrei Zgirvaci #
# Github: https://github.com/MD3XTER/hide-me #
####################################################################################
__name__ = "hide-me"
__version__ = " "
import sys
def usage():
print (__name__+__version__)
print ("mac and hostname random changer\n")
print ("usage: "+__name__+" device [file_location]\n")
print ("Try "+__name__+" -h for more options.")
exit()
def help():
print (__name__+__version__)
print ("mac and hostname random changer\n")
print ("usage: "+__name__+" device [file_location]\n")
print (" -h, --help Print this help")
print (" [file_location] Indicate file location with hostnames")
print (" quit Retrieve changes to original\n")
print ("Report bugs to https://github.com/MD3XTER/"+__name__+"/issues.")
exit()
total = len(sys.argv)
if total == 3:
import os
import subprocess
def error():
print ("Script encounter an error, sorry...\n")
exit()
def runcommand(string):
try:
subprocess.call([string], shell=True)
return True
except:
error()
def interfaceup(interface):
if runcommand("ifconfig "+interface+" up"):
runcommand("service network-manager restart")
print ("\nInterface should be up!!!\n")
else:
error()
def hostname():
tmphost = str(subprocess.check_output("hostname", shell=True)[:-1])
tmphost = tmphost[1:]
tmphost = tmphost.replace("'", "")
return tmphost
def change(interface):
#changing mac address to a random one
print ("\nChanging mac address... \n")
runcommand("macchanger -A "+interface)
#changing hostname to a random line from file
print ("\nChanging Hostname...\n")
print ("Previus Hostname: "+hostname())
runcommand("hostname "+line)
print ("Current Hostname: "+hostname()+"")
#putting interface up
interfaceup(interface)
def retrieve(interface, oldhost):
#change mac address back to original one
print ("\nChanging macc address to permanent one...\n")
runcommand("ifconfig "+interface+" down")
runcommand("macchanger -p "+interface)
#change hostname back to original one
print ("\nRetrieving hostname to original...\n")
runcommand("hostname "+oldhost)
print ("Hostname changed to: "+hostname()+"\n")
#putting interface up
interfaceup(interface)
#check if interface exists
checkINTERFACE = str(os.listdir('/sys/class/net/'))
if str(sys.argv[1]) in checkINTERFACE:
#declare interface
interface = str(sys.argv[1])
if os.path.isfile(str(sys.argv[2])):
#pick a random line from file
import random
lines = open(str(sys.argv[2])).read().splitlines()
line = random.choice(lines)
else:
print (__name__+__version__)
print ("mac and hostname random changer\n")
print ("[ERROR] File does not exist.\n")
print ("Try "+__name__+" -h for more options.")
exit()
if runcommand("ifconfig "+interface+" down"):
oldhost = hostname()
#change mac address and hostname
change(interface)
#whait for 'quit' input
while True:
var = input("Type 'quit', to retrieve changes to original: ")
if var == "quit":
break
#Retrieve changes
retrieve(interface, oldhost)
else:
error()
else:
print (__name__+__version__)
print ("mac and hostname random changer\n")
print ("[ERROR] Set device name: No such device.\n")
print ("Try "+__name__+" -h for more options.")
exit()
elif total == 2:
if (sys.argv[1] == "-h" or sys.argv[1] == "--help"):
help()
else:
usage()
else:
usage()