This repository has been archived by the owner on Jun 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cwclient.py
executable file
·55 lines (48 loc) · 1.69 KB
/
cwclient.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
#!/usr/bin/env python
# -*- Mode: Python; tab-width: 4 -*-
#
# Client for clamd - old proto (newline)
#
# Copyright (C) 2009 Gianluigi Tiesi <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
# ======================================================================
from socket import socket, AF_INET, SOCK_STREAM
from os import getcwd
from os.path import join as path_join
EICAR='*H+H$!ELIF-TSET-SURIVITNA-DRADNATS-RACIE$}7)CC7)^P(45XZP\\4[PA@%P!O5X'[::-1]
def connect():
s = socket(AF_INET, SOCK_STREAM)
s.connect(('localhost', 3310))
f = s.makefile('rw', 0)
return f
if __name__ == '__main__':
f = connect()
f.write('SESSION\n')
filename = path_join(getcwd(), 'clam.exe')
f.write('SCAN ' + filename + '\n')
print f.readline().strip()
f.write('STREAM\n')
port = int(f.readline().strip().split('PORT ', 1).pop())
s = socket(AF_INET, SOCK_STREAM)
s.connect(('localhost', port))
s.send(EICAR)
s.close()
print f.readline().strip()
f.write('STREAM\n')
port = int(f.readline().strip().split('PORT ', 1).pop())
s = socket(AF_INET, SOCK_STREAM)
s.connect(('localhost', port))
s.send(open('clam.exe', 'rb').read())
s.close()
print f.readline().strip()
f.write('END\n')
f.close()