mirror of https://github.com/n1nj4sec/pupy.git
Try to retrieve proxies from all users
This commit is contained in:
parent
60ff7ccea5
commit
798f266f22
|
@ -36,45 +36,41 @@ def parse_win_proxy(val):
|
|||
return l
|
||||
|
||||
def get_win_proxies():
|
||||
#TODO retrieve all users proxy settings, not only HKCU
|
||||
try:
|
||||
from _winreg import OpenKey, CloseKey, QueryValueEx, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, KEY_QUERY_VALUE
|
||||
from _winreg import EnumKey, OpenKey, CloseKey, QueryValueEx
|
||||
from _winreg import HKEY_LOCAL_MACHINE, HKEY_USERS, KEY_QUERY_VALUE
|
||||
except:
|
||||
return
|
||||
|
||||
aKey = OpenKey(
|
||||
HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
0, KEY_QUERY_VALUE
|
||||
)
|
||||
duplicates = set()
|
||||
|
||||
try:
|
||||
value = QueryValueEx(aKey, 'ProxyServer')[0]
|
||||
if value:
|
||||
for p in parse_win_proxy(value):
|
||||
yield p
|
||||
i = 0
|
||||
while True:
|
||||
try:
|
||||
user = EnumKey(HKEY_USERS, i)
|
||||
i += 1
|
||||
except:
|
||||
break
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
if user.endswith('_classes'):
|
||||
continue
|
||||
|
||||
finally:
|
||||
CloseKey(aKey)
|
||||
try:
|
||||
key = '{}\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'.format(user)
|
||||
aKey = OpenKey(HKEY_USERS, key, 0, KEY_QUERY_VALUE)
|
||||
value = QueryValueEx(aKey, 'ProxyServer')[0]
|
||||
if value:
|
||||
for p in parse_win_proxy(value):
|
||||
if p not in duplicates:
|
||||
yield p
|
||||
duplicates.add(p)
|
||||
|
||||
aKey = OpenKey(
|
||||
HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
0, KEY_QUERY_VALUE
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
value=QueryValueEx(aKey,'ProxyServer')[0]
|
||||
if value:
|
||||
for p in parse_win_proxy(value):
|
||||
yield p
|
||||
finally:
|
||||
CloseKey(aKey)
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
finally:
|
||||
CloseKey(aKey)
|
||||
|
||||
def get_python_proxies():
|
||||
global PROXY_MATCHER
|
||||
|
|
Loading…
Reference in New Issue