Skip to content

Instantly share code, notes, and snippets.

@deajan

deajan/burpdebug.cmd

Last active Sep 6, 2018
Embed
What would you like to do?
@echo off
:: quick and dirty burp debug script
setlocal enabledelayedexpansion
set curdir=%~dp0
set curdir=%curdir:~0,-1%
set curdrive=%~d0
:: ::::::::::::::::::::::::::::::::::::::::::: OPTIONS
set burp_server_fqdn=some.burp.server.example.org
set burp_log_file=%curdir%\burp_client.log
set ping_3rdparty_log_file=%curdir%\ping_3rdparty.log
set ping_burp_log_file=%curdir%\ping_burp.log
set script_log=%curdir%\burpdebug.log
set syslog=%curdir%\system.csv
set applog=%curdir%\application.csv
:: Alert email send options
set SEND_ALERTS=yes
set SMTP_SERVER=smtp.server.com
set SMTP_PORT=25
:: Optional user and password (comment out both in order to not use them)
set SMTP_USER=
:: You can set a clear text SMTP password here
set SMTP_PW=
set SENDER=%SMTP_USER%
set RECEIVER=mymail@me.com
set SUBJECT=BURP BACKUP DEBUG LOGS
set MAIL_CONTENT=Burp run on %COMPUTERNAME%.%USERDNSDOMAIN%
:: Mail server encryption, possible values are tls, ssl, none
set SECURITY=tls
:: ::::::::::::::::::::::::::::::::::::::::::: END OPTIONS
IF "%1"=="ping_burp" GOTO PING_BURP_SERVER
IF "%1"=="ping_3rdparty" GOTO PING_3RDPARTY
:: Get local os time before running burp
FOR /F "tokens=*" %%g IN ('wmic os get LocalDateTIme ^| findstr "." ') do SET scriptbegintstamp=%%g
call:CheckMailValues
IF EXIST "%burp_log_file%" DEL /F /S /Q "%burp_log_file%"
IF EXIST "%ping_3rdparty_log_file%" DEL /F /S /Q "%ping_3rdparty_log_file%"
IF EXIST "%ping_burp_log_file%" DEL /F /S /Q "%ping_burp_log_file%"
IF EXIST "%script_log%" DEL /F /S /Q "%script_log%"
call:Log "Beginning new run" "%script_log%"
call:Log "Beginning new run" "%burp_log_file%"
call:Log "Beginning new run" "%ping_3rdparty_log_file%"
call:Log "Beginning new run" "%ping_burp_log_file%"
:PREPAREPING
for /f "tokens=2 delims==; " %%a in (' wmic process call create "cmd /c ""%curdir%\burpdebug.cmd"" ping_burp" ^| find "ProcessId" ') do set BURP_PING_PID=%%a
call:Log "Running burp_ping with pid %BURP_PING_PID%" "%script_log%"
for /f "tokens=2 delims==; " %%b in (' wmic process call create "cmd /c ""%curdir%\burpdebug.cmd"" ping_3rdparty" ^| find "ProcessId" ') do set PING_3RDPARTY_PID=%%b
call:Log "Running burp_ping with pid %PING_3RDPARTY_PID%" "%script_log%"
netstat -ra >> "%script_log%" 2>&1
netsh wlan show interfaces >> "%script_log%" 2>&1
Netsh WLAN show WLANreport >> "%script_log%" 2>&1
netsh wlan show drivers >> "%script_log%" 2>&1
"%curdir%\burp.exe" -a t >> "%burp_log_file%" 2>&1
SET EXITCODE=%ERRORLEVEL%
TASKKILL /PID %BURP_PING_PID% /F /T
TASKKILL /PID %PING_3RDPARTY_PID% /F /T
wmic NTEVENT WHERE "LogFile='system' AND TimeGenerated > '%scriptbegintstamp%'" GET LogFile, SourceName, EventType, Message, TimeGenerated /format:csv > "%syslog%"
wmic NTEVENT WHERE "LogFile='application' AND TimeGenerated > '%scriptbegintstamp%'" GET LogFile, SourceName, EventType, Message, TimeGenerated /format:csv > "%applog%"
IF %EXITCODE% NEQ 3 call:MailerMailSend
exit %EXITCODE%
GOTO END
:PING_3RDPARTY
ping google.com -t >> "%ping_3rdparty_log_file%"
GOTO END
:PING_BURP_SERVER
ping %burp_server_fqdn% -t >> "%ping_burp_log_file%"
GOTO END
:CheckMailValues
echo "%SENDER%" | findstr /I "@" > nul
IF %ERRORLEVEL%==1 (
call:Log "Source mail not set" "%script_log%"
GOTO End
)
echo "%RECEIVER%" | findstr /I "@" > nul
IF %ERRORLEVEL%==1 (
call:Log "Destination Mail not Set" "%script_log%"
GOTO End
)
IF "%SUBJECT%"=="" (
call:Log "Mail subject not set" "%script_log%"
GOTO End
)
echo "%SMTP_SERVER%" | findstr /I "." > nul
IF %ERRORLEVEL%==1 (
call:Log "Smtp sever not set" "%script_log%"
GOTO End
)
call:Log "Configuration file check success." "%script_log%"
GOTO:EOF
:MailerMailSend
set attachment=-attach "%burp_log_file%" -attach "%ping_3rdparty_log_file%" -attach "%ping_burp_log_file%" -attach "%syslog%" -attach "%applog%"
IF "%SECURITY%"=="tls" set encryption=-starttls
IF "%SECURITY%"=="ssl" set encryption=-ssl
IF NOT "%SMTP_USER%"=="" set smtpuser=-auth -user %SMTP_USER%
IF NOT "%SMTP_PW%"=="" set smtppassword=-pass %SMTP_PW%
"%curdir%\mailsend.exe" -f "%SENDER%" -t "%RECEIVER%" -sub "%SUBJECT%" -M "%MAIL_CONTENT%" %attachment% -smtp "%SMTP_SERVER%" -port %SMTP_PORT% %smtpuser% %smtppassword% %encryption% -log "%script_log%"
IF NOT %ERRORLEVEL%==0 set SCRIPT_ERROR=1 && call:Log "Sending mail using mailsend failed." "%script_log%"
GOTO:EOF
:GetDateStamp
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%"
set "Min=%dt:~10,2%"
set "Sec=%dt:~12,2%"
set datestamp=%YYYY%%MM%%DD%
GOTO:EOF
:: Arguments: 1: String to log ; [2]: Log file
:Log
call:GetDateStamp
echo %YYYY%/%MM%/%DD% - %HH%:%Min%:%Sec% %~1 >> "%~2"
echo %~1
GOTO:EOF
:END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.