-
Notifications
You must be signed in to change notification settings - Fork 0
/
Web_scan.py
48 lines (30 loc) · 1.17 KB
/
Web_scan.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
from flask import Flask, flash, request, redirect, url_for,render_template ,send_from_directory
import os
from flask.templating import render_template_string
import yara
from werkzeug.utils import secure_filename
from pathlib import Path
location='/home/harishankar/v2/scanfile'
app = Flask(__name__, template_folder='templates')
app.config['location'] = location
@app.route('/uploade')
def upload():
return render_template('index.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
fl = request.files['file']
filenmae = secure_filename(fl.filename)
fl.save(os.path.join(app.config['location'], filenmae))
rules= yara.compile('/home/harishankar/v2/malware_index.yar')
entries = Path('/home/harishankar/v2/scanfile/')
for entry in entries.iterdir():
#with open(entry.name) as f:
# matches = rules.match(data=f.read())
matches = rules.match('/home/harishankar/v2/scanfile/{{entery.name}}')
return f'{matches}'
#@app.route('/<usr>')
#def files(usr):
# return 'file got '
if __name__ == "__main__":
app.run(debug=True)