NTLM Authorization Proxy Server

The ‘NTLM Authorization Proxy Server’ (APS) is a proxy software that allows you to authenticate via an MS Proxy Server using the proprietary NTLM protocol. APS has the ability to behave as a standalone proxy server and authenticate HTTP clients at Web servers using the NTLM protocol. It can change arbitrary values in your client’s request headers so that those requests will look like they were created by MS IE. It is written in Python 1.5.2.


Python HTTP proxy server

from twisted.web import proxy, http
from twisted.internet import reactor
from twisted.python import log
import sys

class ProxyFactory(http.HTTPFactory):
    protocol = proxy.Proxy

reactor.listenTCP(8080, ProxyFactory())
  • Execute the above Twisted python example script (python proxy.py) You may see a Deprecation Warning that you can ignore for this example.


[jacob@tux]$ python proxy.py
/usr/lib/python2.3/site-packages/twisted/web/proxy.py:22: DeprecationWarning: twisted.protocols.http has moved to twisted.web.http. See http://twistedmatrix.com/projects/web.
  from twisted.protocols import http
2005/12/06 21:47 EST [-] Log opened.
2005/12/06 21:47 EST [-] __main__.ProxyFactory starting on 8080
2005/12/06 21:47 EST [-] Starting factory <__main__.ProxyFactory instance at 0xb73577ac>
  • Connect your internet browser to the proxy server you just created (localhost:8080) and you have written a simple proxy server using Python and Twisted.

Complicated proxy with urrllib2

For more complicated programs

import urllib2 
def get_proxy_opener(proxyurl, proxyuser, proxypass, proxyscheme="http"): 
    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() 
    password_mgr.add_password(None, proxyurl, proxyuser, proxypass) 
    proxy_handler = urllib2.ProxyHandler({proxyscheme: proxyurl}) 
    proxy_auth_handler = urllib2.ProxyBasicAuthHandler(password_mgr) 
    return urllib2.build_opener(proxy_handler, proxy_auth_handler) 
if __name__ == "__main__": 
    import sys 
    if len(sys.argv) > 4: 
        url_opener = get_proxy_opener(*sys.argv[1:4]) 
        for url in sys.argv[4:]: 
            print url_opener.open(url).headers 
        print "Usage:", sys.argv[0], "proxy user pass fetchurls..." 

Python Proxy Source 2

import urllib2 
url = 'www.example.com' 
username = 'user' 
password = 'pass' 
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() 
# None, with the "WithDefaultRealm" password manager means 
# that the user/pass will be used for any realm (where 
# there isn't a more specific match). 
password_mgr.add_password(None, url, username, password) 
auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr) 
opener = urllib2.build_opener(auth_handler) 
print urllib2.urlopen("http://www.example.com/folder/page.html") 

Python Proxy Source

import urllib2, urllib 

proxy = urllib2.ProxyHandler({'http': 'http:// 
auth = urllib2.HTTPBasicAuthHandler() 
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler) 

conn = urllib2.urlopen('http://python.org') 
return_str = conn.read() 

Geolog Scripts

This is a test of some of the scripts in Geolog

To get a list of all the projects  log_dbms mode=list project=_all

To get a list of all the wells in a project:

1. Set PG_PROJECT to the name of the project

2. log_dbms mode=list select=_project well=_all

1 154 155 156