Jump to content

Python server not continuous on BB


Dave-ee Jones

Recommended Posts

Hey all,

I've got a problem with my python server. The Bash Bunny doesn't want to handle it forever, so it seems to stop handling after about 5 seconds (or shutting it down, can't tell which). The exact same code works locally on my computer (python script that runs a simple SocketServer), and it runs forever (using httpd.serve_forever()), however the BB doesn't want to run it forever.

Any ideas why the BB stops handling?

 

EDIT: Just for those that are interested, the browser error says "Site cannot be reached; connection was reset (ERR_CONNECTION_RESET)".

Edited by Dave-ee Jones
Link to comment
Share on other sites

1 hour ago, Sebkinne said:

Without seeing what python code you are running, we can't really help you :)

Generic HTTPServer script (this is my SimpleHTTPServer version, CGI was basically the same except I added a cgi_directory).

import etc, etc, etc.

rootdir = os.getcwd()
global bRunning
bRunning = True

class http_handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
	
	def do_GET(self):
		found_type = ''
		if self.path.endswith('/'):
			self.path = '/index.html'
			found_type = 'text/html'
		try:
			if self.path.endswith('.html'):
				found_type = 'text/html'
			if self.path.endswith('.css'):
				found_type = 'text/css'
			if self.path.endswith('.js'):
				found_type = 'application/javascript'
			if self.path.endswith('.php') or self.path.endswith('.txt') or self.path.endswith('.md'):
				found_type = 'text/plain'
				
			if found_type != '':
				self.send_response(200)
				self.send_header('Content-type',found_type)
				self.end_headers()
				f = open(rootdir + self.path,'r')
				self.wfile.write(f.read())
				f.close()
				if found_type == 'text/html' and self.path.endswith('exit.html'):
					global bRunning
					bRunning = False
				
			return
			
		except IOError:
			self.send_error(404,'File not found: %s' % (rootdir + self.path))

def run():
	httpd = SocketServer.TCPServer(('0.0.0.0',8080),http_handler)
	while bRunning:
		httpd.handle_request()
	
run()

Also, just to let you know, I'm playing around with PHP's in-built server and it isn't serving me well either (pun intended).
 

Link to comment
Share on other sites

I've been also working with a HTTP Python server with firmware 1.1 of the Bunny and I discovered that sometimes, when you reach the end of the payload, the server stop working. But it doesn't happen all the time, it's like the bunny kills the payload. If it happens, you can see the LED switched off.

Put a "sleep 60" a the end of the payload and see if this is the same error.

 

Link to comment
Share on other sites

14 hours ago, oXis said:

I've been also working with a HTTP Python server with firmware 1.1 of the Bunny and I discovered that sometimes, when you reach the end of the payload, the server stop working. But it doesn't happen all the time, it's like the bunny kills the payload. If it happens, you can see the LED switched off.

Put a "sleep 60" a the end of the payload and see if this is the same error.

 

Yes, I noticed other people had issues with their payloads stopping. Apparently the bug came out with 1.1.

Just confirming, you did say you would fix that in 1.2 correct, @Sebkinne?

EDIT: Also, for some reason whenever my BB is in the RNDIS_ETHERNET attackmode, any requests I make to the internet (e.g. trying to access Google) fail. Meaning, the BB is apparently overriding everything, which means I cannot share internet between BB and computer. Waddaya think?

Edited by Dave-ee Jones
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...