Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
arbs09 committed Mar 19, 2024
1 parent b85111a commit 2514b08
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
MALICIOUS_USER_AGENTS = ["Go-http-client", "python", "sqlmap", "Nmap Scripting Engine", "pycurl"]

def report_ip(ip, categories, comment):
url = 'https://api.abuseipdb.com/api/v2/report'
headers = {
'Key': ABUSEIPDB_API_KEY,
'Content-Type': 'application/x-www-form-urlencoded'
}
payload = {
'ip': ip,
'categories': categories,
'comment': comment
}
response = requests.post(url, headers=headers, data=payload)
return response.json()
url = 'https://api.abuseipdb.com/api/v2/report'
headers = {
'Key': ABUSEIPDB_API_KEY,
'Content-Type': 'application/x-www-form-urlencoded'
}
payload = {
'ip': ip,
'categories': categories,
'comment': comment
}
response = requests.post(url, headers=headers, data=payload)
return response.json()

def save_to_file(ip):
timestamp = datetime.now().strftime('%Y.%m.%d %H:%M')
Expand All @@ -33,12 +33,12 @@ def save_to_file(ip):

@app.before_request
def get_client_ip():
global request # Modify the global request object
request.client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
global request # Modify the global request object
request.client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)

@app.route('/', methods=['GET', 'POST'])
def index():
return render_template('index.html')
return render_template('index.html')

@app.route("/robots.txt")
def send_robots():
Expand All @@ -55,34 +55,34 @@ def send_robots():
@app.route('/wp-includes/<path:path>', methods=['GET', 'POST'])
@app.route('/wp-includes/', methods=['GET', 'POST'])
def wp_vulnerability_scan(path=None):
ip = request.client_ip
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
report_ip(ip, '18,19,21,15', 'Automated report for WordPress vulnerability scanning')
reported_ips[ip] = datetime.now()
return '404'
ip = request.client_ip
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
report_ip(ip, '18,19,21,15', 'Automated report for WordPress vulnerability scanning')
reported_ips[ip] = datetime.now()
return '404'

@app.route('/.vscode/<path:path>', methods=['GET', 'POST'])
@app.route('/.git/<path:path>', methods=['GET', 'POST'])
def sensitive_folders_access(path=None):
ip = request.client_ip
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
folder_name = request.path.split('/')[1]
report_ip(ip, '18,19,21,15', f'Automated report for accessing {folder_name} folder')
reported_ips[ip] = datetime.now()
return '404'

@app.before_request
def check_path():
if '../' in request.path:
ip = request.client_ip
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
report_ip(ip, '18,19,21,15', 'Automated report for attempting to traverse directories')
reported_ips[ip] = datetime.now()
save_to_file(ip)
folder_name = request.path.split('/')[1]
report_ip(ip, '18,19,21,15', f'Automated report for accessing {folder_name} folder')
reported_ips[ip] = datetime.now()
return '404'

@app.before_request
def check_path():
if '../' in request.path:
ip = request.client_ip
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
report_ip(ip, '18,19,21,15', 'Automated report for attempting to traverse directories')
reported_ips[ip] = datetime.now()
return '404'

@app.before_request
def check_user_agent():
user_agent = request.headers.get("User-Agent")
Expand All @@ -98,13 +98,13 @@ def check_user_agent():

@app.route('/<path:filename>')
def report_rules(filename):
ip = request.client_ip
if filename in ['xmlrpc.php', 'check.js', 'my1.php', '.env', 'admin.php', 'wlwmanifest.xml', '.DS_Store', '.htaccess', 'core.js', 'install.php', 'config.php', 'st.php', 'repeater.php', 'dropdown.php', 'cjfuns.php', 'file.php', '_all_dbs', 'config.json', 'login.action', 'sftp.json', 'style.php', 'setup-config?step=1', 'hetong.js', 'ae.php', 'moon.php', 'wp-sigunq.php', 'jquery.query.js', 'ajax-actions.php', 'admin-post.php', 'repeater.php', 'install.php', 'plugins.php', 'shell.php', 'wp.php', 'wp-config.php-backup', 'config', 'wp-emoji-release.min.js', 'HEAD', 'wp_filemanager.php']:
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
report_ip(ip, '18,19,21,15', f'Automated report for accessing {filename} on my Honeypot')
reported_ips[ip] = datetime.now()
return '404'
ip = request.client_ip
if filename in ['xmlrpc.php', 'check.js', 'my1.php', '.env', 'admin.php', 'wlwmanifest.xml', '.DS_Store', '.htaccess', 'core.js', 'install.php', 'config.php', 'st.php', 'repeater.php', 'dropdown.php', 'cjfuns.php', 'file.php', '_all_dbs', 'config.json', 'login.action', 'sftp.json', 'style.php', 'setup-config?step=1', 'hetong.js', 'ae.php', 'moon.php', 'wp-sigunq.php', 'jquery.query.js', 'ajax-actions.php', 'admin-post.php', 'repeater.php', 'install.php', 'plugins.php', 'shell.php', 'wp.php', 'wp-config.php-backup', 'config', 'wp-emoji-release.min.js', 'HEAD', 'wp_filemanager.php']:
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
save_to_file(ip)
report_ip(ip, '18,19,21,15', f'Automated report for accessing {filename} on my Honeypot')
reported_ips[ip] = datetime.now()
return '404'

if __name__ == '__main__':
app.run(debug=False,port=80, host="0.0.0.0")
app.run(debug=False, port=80, host="0.0.0.0")

0 comments on commit 2514b08

Please sign in to comment.