Instantly share code, notes, and snippets.

anonymous /push.py
Created Jan 4, 2018

Embed
What would you like to do?
CSIDL pusher
#!/usr/bin/env python3
# https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx
import sys
import uuid
import requests
class FOLDERID:
def __init__(self,name):
self.name = name
self.properties = {}
def load(self,line):
fields = line.split('\t')
field_names = [
'GUID',
'Display Name',
'Folder Type',
'Default Path',
'CSIDL',
'CSIDL Equivalent',
'CSIDL Equivalents',
'Legacy Display Name',
'Legacy Default Path',
]
for field in fields:
if field.strip() in field_names:
current_field = field
else:
if self.properties.get(current_field) is None:
self.properties[current_field] = field
else:
self.properties[current_field] += '@'+field
try:
self.xuuid = uuid.UUID(self.properties.get('GUID')[1:-1])
except ValueError as e:
print(self)
raise(e)
def push(self):
push_web(
self.xuuid,
self.properties['Display Name'],
str(self)+"\nfrom https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx",
"KNOWNFOLDERID push",
)
def __str__(self):
return '\n'.join(['{:15s}\t{}'.format(k,self.properties.get(k)) for k in self.properties])
def push_web(x_uuid,name,comment,author='automated push'):
url = 'https://uuid.pirate-server.com/{}'.format(x_uuid)
r = s.get(url)
try:
csrfmiddlewaretoken = r.text.split("csrfmiddlewaretoken' value='")[1].split("'")[0]
except Exception as e:
print(r.text)
raise(e)
r = s.post('https://uuid.pirate-server.com/comment',headers={'Referer':url},data={
'csrfmiddlewaretoken':csrfmiddlewaretoken,
'title':name,
'details':comment,
'author':author,
})
print('{} {}'.format(x_uuid,name))
if __name__ == '__main__':
s = requests.session()
with open('folderid.txt') as o:
lines = o.readlines()
folderids = []
for line in lines:
if line[:len('FOLDERID_')] == 'FOLDERID_':
folderids.append(FOLDERID(line.strip()))
elif line[:len('GUID')] == 'GUID':
folderids[-1].load(line)
started = False
for folderid in folderids:
if folderid.properties.get('GUID') is not None:
if started:
folderid.push()
else:
print('Skipping :')
print(folderid)
if folderid.properties.get('Display Name') == 'Recent Items':
started = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment