-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathsms_forward.py
53 lines (45 loc) · 1.07 KB
/
sms_forward.py
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
#!/usr/bin/python
#!coding=utf-8
import socket
import struct
import threading
import Queue
import time
import subprocess
import re
import os
from scapy.all import sniff, UDP
import pdb
g_listen_udp_dst_port = 4729;
g_forward_udp_port = 47290;
g_q = Queue.Queue();
g_set = set();
g_s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
def recv_new_data(p):
#pdb.set_trace();
if g_listen_udp_dst_port != int(p[UDP].dport):
return
udpdata = str(p[UDP].payload)
_b_find = 0;
for s_key in g_set:
if s_key==udpdata:
_b_find = 1;
break;
if _b_find == 0:
g_set.clear();
g_set.add(udpdata);
#print udpdata.encode('hex')
g_s.sendto(udpdata, ("127.0.0.1", g_forward_udp_port));
if __name__ == '__main__':
try:
#while True:
str_filter = 'udp and port %d' % g_listen_udp_dst_port;
sniff(iface='lo', filter=str_filter, prn=recv_new_data,count = 0 ,store=0 )
except KeyboardInterrupt:
try:
child1.kill()
child2.kill()
child3.kill()
print "[-]Kill Process Done."
except:
pass