mirror of https://github.com/hak5/ToorChat.git
What looks like it might be it for website thigns
parent
97bcabd19f
commit
4a44823e95
|
@ -20,14 +20,11 @@ def get_web_site(visual, site):
|
||||||
connection.request("GET", "/")
|
connection.request("GET", "/")
|
||||||
result = connection.getresponse().read()
|
result = connection.getresponse().read()
|
||||||
result_list = string_into_even_peices(result, 200)
|
result_list = string_into_even_peices(result, 200)
|
||||||
site_xid = os.urandom(8)
|
length = "%0*d" % (4, len(result_list)-1)
|
||||||
length = "%0*d" % (4, len(result_list))
|
|
||||||
|
|
||||||
for index, item in enumerate(result_list):
|
for index, item in enumerate(result_list):
|
||||||
index = "%0*d" % (4, index)
|
index = "%0*d" % (4, index)
|
||||||
msg = ToorMessage(item, None, ToorChatProtocol.get_web_response_type(), site_xid, index, length)
|
msg = ToorMessage(item, None, ToorChatProtocol.get_web_response_type(), visual.request_xid, index, length)
|
||||||
visual.protocol.send_message(msg)
|
visual.protocol.send_message(msg)
|
||||||
# visual.message_queue.append(msg)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print e
|
||||||
|
|
||||||
|
@ -65,6 +62,7 @@ class ToorChatProtocol():
|
||||||
if site != "":
|
if site != "":
|
||||||
request = ToorMessage(site, None, ToorChatProtocol.get_web_request_type())
|
request = ToorMessage(site, None, ToorChatProtocol.get_web_request_type())
|
||||||
self.device.RFxmit(request.to_string())
|
self.device.RFxmit(request.to_string())
|
||||||
|
return request
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_message(cls, raw_message):
|
def parse_message(cls, raw_message):
|
||||||
|
|
20
toorchat.py
20
toorchat.py
|
@ -10,6 +10,14 @@ import curses
|
||||||
import time
|
import time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
|
def find_message_in_website(message, visual):
|
||||||
|
found = False
|
||||||
|
for item in visual.website_buffer:
|
||||||
|
if message.index == item.index:
|
||||||
|
found = True
|
||||||
|
if not found:
|
||||||
|
visual.website_buffer.append(message)
|
||||||
|
|
||||||
def thread_run(visual):
|
def thread_run(visual):
|
||||||
''' This is our function for the thread '''
|
''' This is our function for the thread '''
|
||||||
#Thread should run until exit
|
#Thread should run until exit
|
||||||
|
@ -24,6 +32,14 @@ def thread_run(visual):
|
||||||
#If we are registered as a server, lets type to make that request
|
#If we are registered as a server, lets type to make that request
|
||||||
if visual.server:
|
if visual.server:
|
||||||
ToorChatProtocol.get_web_messages(toor_message.data, visual)
|
ToorChatProtocol.get_web_messages(toor_message.data, visual)
|
||||||
|
if toor_message.type == ToorChatProtocol.get_web_response_type():
|
||||||
|
# lets see if its the response were looking for
|
||||||
|
if toor_message.xid == visual.request_xid:
|
||||||
|
index = find_message_in_website(toor_message, visual)
|
||||||
|
if len(website_buffer) == toor_message.last:
|
||||||
|
#sort messages
|
||||||
|
#Render website
|
||||||
|
print "Winner winner chicken dinners!!"
|
||||||
|
|
||||||
except ChipconUsbTimeoutException:
|
except ChipconUsbTimeoutException:
|
||||||
pass
|
pass
|
||||||
|
@ -41,6 +57,7 @@ class Visualizer():
|
||||||
self.user = None
|
self.user = None
|
||||||
self.channel = None
|
self.channel = None
|
||||||
self.frequency = None
|
self.frequency = None
|
||||||
|
self.request_xid = None
|
||||||
#This when set to True will kill the thread
|
#This when set to True will kill the thread
|
||||||
self.exit = False
|
self.exit = False
|
||||||
self.server = False
|
self.server = False
|
||||||
|
@ -98,7 +115,8 @@ class Visualizer():
|
||||||
if entry == ord('w'):
|
if entry == ord('w'):
|
||||||
self.screen.nodelay(0)
|
self.screen.nodelay(0)
|
||||||
user_input = self.screen.getstr(1, 1, 60)
|
user_input = self.screen.getstr(1, 1, 60)
|
||||||
self.protocol.send_web_request(user_input)
|
request = self.protocol.send_web_request(user_input)
|
||||||
|
self.request_xid = request.xid
|
||||||
self.screen.nodelay(1)
|
self.screen.nodelay(1)
|
||||||
self.screen.addstr(1,1," "*(self.screen_max_x-3))
|
self.screen.addstr(1,1," "*(self.screen_max_x-3))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue