def create_connection(addr, port): con = Spin() Client(con) xmap(con, CONNECT, on_connect, addr, port) xmap(con, CONNECT_ERR, on_connect_err, addr, port) xmap(con, CONNECT, lambda con: die()) xmap(con, CONNECT_ERR, lambda con, err: die()) con.connect_ex((addr, port))
def main(addr, port, host): sock = socket(AF_INET, SOCK_STREAM) context = ssl.create_default_context() con = SSL( context.wrap_socket(sock, do_handshake_on_connect=False, server_hostname=host)) con.connect_ex((addr, port)) ClientSSL(con) xmap(con, SSL_CONNECT, on_connect, host) xmap(con, SSL_CONNECT_ERR, lambda con, err: die(err)) xmap(con, SSL_CERTIFICATE_ERR, lambda con, err: die(err))
def scan(addr, min, max): task = Task() for ind in range(min, max): task.add(create_connection(addr, ind), CONNECT, CONNECT_ERR) task.start() xmap(task, DONE, lambda task: die())
def scan(addr, min, max): task = Task() for ind in xrange(min, max): task.add(create_connection(addr, ind), CONNECT, CONNECT_ERR) task.start() xmap(task, DONE, lambda task: die())
from untwisted.expect import Expect, LOAD, CLOSE from untwisted.network import core, xmap, die def handle(expect, data): print data expect = Expect('python', '-i', '-u') xmap(expect, LOAD, handle) xmap(expect, CLOSE, lambda expect: die()) expect.send('print "hello world"\nquit()\n') core.gear.mainloop()
def on_close(expect): print('Closing..') die()
def handle_http_response(spin, version, code, reason, header, data): print 'data', repr(data) print 'version', version print 'code', code print 'header', header die()
def handle_http_response(spin, version, code, reason, header, data): print 'URL:%s' % header['Location'] die()