-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflaskapp.py
64 lines (53 loc) · 2.2 KB
/
flaskapp.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
from flask import Flask,render_template,request,jsonify
from werkzeug.utils import secure_filename
import os,pefileparser,win32apiparser,itwordparser
import requests
app=Flask(__name__)
uploadFolder='./templates/uploads'
ALLOWED_EXTENSIONS=set(['exe','dll'])
app.config['UPLOAD_FOLDER']=uploadFolder
def allowedFile(fileName):
return '.' in fileName and fileName.rsplit('.',1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/')
def home():
return render_template('index.html')
@app.route('/upload_exe',methods=['GET','POST'])
def uploadEXE():
fileUploaded=request.files['resume']
if fileUploaded.filename=='':
return jsonify('{"error":"No file Selected"}')
if fileUploaded and allowedFile(fileUploaded.filename):
fileUploaded.save(os.path.join(app.config['UPLOAD_FOLDER'],fileUploaded.filename))
#return jsonify('{"Success":"File Uploaded"}')
exportData=pefileparser.parsePEFile(app.config['UPLOAD_FOLDER']+'/'+fileUploaded.filename)
return jsonify(exportData)
return 'Nothing Happens'
@app.route('/get_function_desc',methods=['GET','POST'])
def getFuncDesc():
data = request.form.to_dict(flat=False)
print (request.args.get("func"))
errorDescript,funcDetail=win32apiparser.getFunctionDetail(request.args.get("func"))
print(funcDetail)
try:
if 'Error Found:' in errorDescript:
return jsonify({"error":errorDescript});
else:
return jsonify(funcDetail)
except:
return jsonify({"error":"No Data Return"})
@app.route('/get_itfunc',methods=['GET','POST'])
def getITFuncDesc():
funcName=request.args.get("func")
if funcName.endswith('A'):
funcName=funcName.replace(funcName[len(funcName)-1],'')
if funcName.endswith('W'):
funcName=funcName.replace(funcName[len(funcName)-1],'')
function=itwordparser.getFunctionName(funcName)
functionListData={}
functionListData['funcName']=function
functionListData['funcLink']="http://www.it-word.net/api/capi/en-us/"+function+'.html'
r=requests.get("http://www.it-word.net/api/capi/en-us/"+function+'.html')
print (r.content)
return r.content
if __name__=='__main__':
app.run(host='0.0.0.0',port=80,debug=True)