[SOLVED] Python scripts: Errors importing other modules


#1

I’ve got an odd issue.

Firstly, this worked fine yesterday (maybe I need to reboot?). Now, it’s just failing hard and not properly operating as I need it to.

I’ve got a script, called rewrite_destination_server.py, which interfaces with an SQLite3 database, and pulls out data regarding regex pattern matches for a given host and then determine what to actually do for each request that comes through mitmproxy.

Essentially, upon script loading, it pulls data from the SQLite database, populates an internally-stored dict, and then uses that dict, regexpatterns, and other items in order to determine what web server to actually route a request through.

For example, if the regex pattern is (\w.\.)?example.com, and it has in the SQL row to redirect to localhost on port 80, but keep the same Host header, then it sends a request to http://localhost:80/ requesting the originally requested host for any *.example.com domain (including just example.com).

This script worked fine yesterday, and I haven’t made any system level changes. Problem is, mitmproxy when it loads the script can no longer can find the proper modules, and gives me an ImportError on import sqlite3.

I’m using the MITMProxy 2.0.2 binaries that were built for Linux; is it possible this is the problem and I need to do a from-soruce compile?


#2

WOW I’m an idiot.

It looks like adding a shebang line, #!/usr/bin/python3, to each of the scripts properly fixes the ImportError problems…

I feel stupid/silly now. Sorry for bothering you all.