-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFPR.au3
287 lines (287 loc) · 16 KB
/
FPR.au3
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.3.2.0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <array.au3>
#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("WinTitleMatchMode", -2)
Global $VendorList = "", $BannedExtensions = ""
$VendorList = BinaryToString(InetRead("https://raw.githubusercontent.com/BetaLeaf/False-Positive-Reporter/master/FPR_List.txt", 1))
If $VendorList = "" Then $VendorList = "[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]"
_ArrayInsert($BannedExtensions, BinaryToString(InetRead("https://raw.githubusercontent.com/BetaLeaf/False-Positive-Reporter/master/Banned_Extensions.txt", 1)))
If $BannedExtensions = "" Then Dim $BannedExtensions = [".ADE", ".ADP", ".BAT", ".CHM", ".CMD", ".COM", ".CPL", ".EXE", ".HTA", ".INS", ".ISP", ".JAR", ".JS", ".JSE", ".LIB", ".LNK", ".MDE", ".MSC", ".MSP", ".MST", ".PIF", ".SCR", ".SCT", ".SHB", ".SYS", ".VB", ".VBE", ".VBS", ".VXD", ".WSC", ".WSF", ".WSH"]
startup()
If $cmdlineraw = "-config" Then
setup() ; Run with -config flag to reconfigure.
EndIf
If $cmdlineraw = "" Then setup()
OnAutoItExitRegister("_OnExit")
FileInstall("7za.exe", @TempDir & "\7za.exe", 1)
FileInstall("7za.dll", @TempDir & "\7za.dll", 1)
FileInstall("7zxa.dll", @TempDir & "\7zxa.dll", 1)
FileInstall("Update FPR.exe", "Update FPR.exe", 1)
mail()
Func setup()
#Region ### START Koda GUI section ### Form=
$FalsePositiveSettings = GUICreate(StringTrimRight(@ScriptName, 4) & " Settings", 192, 220, 775, 254, BitOR($GUI_SS_DEFAULT_GUI, $DS_SETFOREGROUND))
$OkButton = GUICtrlCreateButton("Ok", 0, 194, 75, 25)
$CancelButton = GUICtrlCreateButton("Cancel", 116, 194, 75, 25)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Server") Then
Global $serverDefault = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Server")
Else
Global $serverDefault = "smtp.gmail.com"
EndIf
$ServerInput = GUICtrlCreateInput($serverDefault, 65, 9, 121, 21)
$ServerLabel = GUICtrlCreateLabel("Server", 20, 12, 35, 17)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "IPPort") Then
Global $IPPortDefault = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "IPPort")
Else
Global $IPPortDefault = "465"
EndIf
$PortInput = GUICtrlCreateInput($IPPortDefault, 65, 33, 121, 21)
GUICtrlSetLimit(-1, 5)
$PortLabel = GUICtrlCreateLabel("Port", 20, 36, 23, 17)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "FromName") Then
Global $FromNameDefault = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "FromName")
Else
Global $FromNameDefault = "John Smith"
EndIf
$FromEmailInput = GUICtrlCreateInput($FromNameDefault, 65, 57, 121, 21)
$FromEmailLabel = GUICtrlCreateLabel("From", 20, 60, 27, 17)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ToAddress") Then
Global $ToAddressDefault = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ToAddress")
Else
Global $ToAddressDefault = ""
EndIf
$ToEmailInput = GUICtrlCreateInput($ToAddressDefault, 65, 81, 121, 21)
$ToEmailLabel = GUICtrlCreateLabel("To" & @CRLF & "(Custom)", 20, 84, 42, 37)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Username") Then
Global $UsernameDefault = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Username")
Else
Global $UsernameDefault = "[email protected]"
EndIf
$UserInput = GUICtrlCreateInput($UsernameDefault, 65, 115, 121, 21)
$UserLabel = GUICtrlCreateLabel("User", 20, 118, 26, 17)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Password") Then
Global $PasswordDefault = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Password")
Else
Global $PasswordDefault = ""
EndIf
$PassInput = GUICtrlCreateInput($PasswordDefault, 65, 139, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
$PassLabel = GUICtrlCreateLabel("Pass", 20, 142, 27, 17)
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ssl") Then
Global $ssl = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ssl")
Else
Global $ssl = "4"
EndIf
$UseSSL = GUICtrlCreateCheckbox("Use SSL?", 65, 170, 121, 17, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_LEFT))
GUICtrlSetState($UseSSL, $ssl)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $CancelButton
Exit
Case $OkButton
GUISetState(@SW_HIDE)
Global $SmtpServer = GUICtrlRead($ServerInput)
Global $IPPort = GUICtrlRead($PortInput)
Global $FromName = GUICtrlRead($FromEmailInput)
Global $ToAddress = GUICtrlRead($ToEmailInput)
Global $Username = GUICtrlRead($UserInput)
Global $Password = GUICtrlRead($PassInput)
Global $FromAddress = $Username
Global $ssl = GUICtrlRead($UseSSL)
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Server", "REG_SZ", $SmtpServer)
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "IPPort", "REG_SZ", $IPPort)
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "FromName", "REG_SZ", $FromName)
If $ToAddress = "" Then
RegDelete("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ToAddress")
Else
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ToAddress", "REG_SZ", $ToAddress)
EndIf
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Username", "REG_SZ", $Username)
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Password", "REG_SZ", $Password)
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "FromAddress", "REG_SZ", $FromAddress)
RegWrite("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ssl", "REG_SZ", $ssl)
MsgBox($MB_SETFOREGROUND, "False Positive Reporter - Saved!", "To submit a false positive, simply drag & drop your files onto FPR.exe.")
If MsgBox(BitOR($MB_YESNO, $MB_SETFOREGROUND, $MB_APPLMODAL), "False Positive Reporter", "Would you also like to add this to the Send To context menu?") = $IDYES Then FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\AppData\Roaming\Microsoft\Windows\SendTo\AV Vendors (for whitelisting).lnk", @ScriptDir)
Exit MsgBox(BitOR($MB_APPLMODAL, $MB_SETFOREGROUND), "False Positive Reporter", "Done.")
EndSwitch
WEnd
EndFunc ;==>setup
Func startup()
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Server") Then
Global $SmtpServer = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Server")
Else
setup()
EndIf
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "IPPort") Then
Global $IPPort = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "IPPort")
Else
setup()
EndIf
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "FromName") Then
Global $FromName = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "FromName")
Else
setup()
EndIf
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ToAddress") Then
Global $ToAddress = $VendorList
$ToAddress &= ";" & RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ToAddress")
$ToAddress = StringReplace($ToAddress, ";;", ";")
Else
Global $ToAddress = $VendorList
EndIf
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Username") Then
Global $Username = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Username")
Global $FromAddress = $Username
Else
setup()
EndIf
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Password") Then
Global $Password = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "Password")
Else
setup()
EndIf
If RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ssl") Then
Global $ssl = RegRead("HKCU\SOFTWARE\BetaLeaf Software\FalsePositiveReporter", "ssl")
Else
setup()
EndIf
EndFunc ;==>startup
Func mail()
ProgressOn("False Positive Reporter", "")
$Subject = "False Positive" ; subject from the email - can be anything you want it to be
$Body = 'The password to decrypt this archive is "infected".' & @CRLF & @CRLF & "The following files are included in this archive:" & @CRLF & @CRLF
Local $sFileName = ""
Global $tpath = @TempDir & "\" & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "-" & @MIN & "-" & @SEC & "\"
For $i = 1 To $cmdline[0]
ProgressSet($i / $cmdline[0] * 100, "Zipping Files " & $i & " of " & $cmdline[0] & ".")
If StringInStr($cmdline[$i], ".lnk") Then ;Follow Link
Local $shortcut = FileGetShortcut($cmdline[$i])
$cmdline[$i] = $shortcut[0]
EndIf
For $j = 1 To UBound($BannedExtensions) - 1
If StringInStr($cmdline[$i], $BannedExtensions[$j]) Then ;Bypass Email Exe filter.
FileCopy($cmdline[$i], $cmdline[$i] & ".tmp", 1)
$cmdline[$i] &= ".tmp"
EndIf
Next
ShellExecuteWait(@TempDir & '\7za.exe', 'a -tzip "' & $tpath & 'FalsePositives.zip" "' & $cmdline[$i] & '" -pinfected', $tpath, '', @SW_HIDE)
If FileExists(StringTrimRight($cmdline[$i], 4) & ".tmp") Then FileDelete(StringTrimRight($cmdline[$i], 4) & ".tmp")
$aFile = StringSplit($cmdline[$i], "/\")
$Body &= $aFile[$aFile[0]] & @CRLF
Next
Global $AttachFiles = $tpath & "FalsePositives.zip"
$CcAddress = "" ; address for cc - leave blank if not needed
$BccAddress = "" ; address for bcc - leave blank if not needed
$Importance = "High" ; Send message priority: "High", "Normal", "Low"
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
If FileGetSize($AttachFiles) > 25000000 Then
FileMove($AttachFiles, @UserProfileDir & "\Desktop\FPR-Files.zip", 1)
ProgressOff()
MsgBox($MB_SETFOREGROUND, @ScriptName, 'File is too large to send. It has been copied to your desktop as "FPR-Files.zip".')
Exit
EndIf
If FileGetSize($AttachFiles) > 10000000 Then Global $FileOver10MB = 'Some vendors will reject your attachment because it was over 10 mb. Please verify that the email was sent by checking your sent folder. The attachement has been copied to your desktop as "FPR-Files.zip".'
ProgressSet(100, "Sending Email to Anti Virus Vendors." & @CRLF & "This can take a while depending on your upload speed." & @CRLF & "Stand up and stretch while you wait.")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
ProgressOff()
If MsgBox(BitOR($MB_SETFOREGROUND, $MB_ICONERROR, $MB_YESNO), "False Positive Reporter", "Failed to send email. Please check your credentials and smtp settings. Would you like to do so now?" & @CRLF & @CRLF & "Error: " & $rc) = 6 Then ShellExecuteWait(@ScriptFullPath, "-config")
EndIf
EndFunc ;==>mail
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
Local $objEmail = ObjCreate("CDO.Message")
$objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
$objEmail.To = $s_ToAddress
Local $i_Error = 0
Local $i_Error_desciption = ""
If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
$objEmail.Subject = $s_Subject
If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
$objEmail.HTMLBody = $as_Body
Else
$objEmail.Textbody = $as_Body & @CRLF
EndIf
If $s_AttachFiles <> "" Then
Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
For $x = 1 To $S_Files2Attach[0]
$S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
If FileExists($S_Files2Attach[$x]) Then
ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @CRLF)
$objEmail.AddAttachment($S_Files2Attach[$x])
Else
MsgBox($MB_SETFOREGROUND, "Error", 'File not found to attach: ' & $S_Files2Attach[$x])
SetError(1)
Return 0
EndIf
Next
EndIf
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
If Number($IPPort) = 0 Then $IPPort = 25
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;Authenticated SMTP
If $s_Username <> "" Then
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
EndIf
If $ssl = "1" Then
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
;Update settings
$objEmail.Configuration.Fields.Update
; Set Email Importance
Switch $s_Importance
Case "High"
$objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "High"
Case "Normal"
$objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Normal"
Case "Low"
$objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Low"
EndSwitch
$objEmail.Fields.Update
; Sent the Message
$objEmail.Send
If @error Then
SetError(2)
Return $oMyRet[1]
Else
ProgressOff()
If IsDeclared("FileOver10MB") <> 0 Then
FileMove($AttachFiles, @UserProfileDir & "\Desktop\FPR-Files.zip", 1)
MsgBox($MB_SETFOREGROUND, "Email", "Ok. " & @CRLF & @CRLF & $FileOver10MB)
Else
MsgBox($MB_SETFOREGROUND, "Email", "Ok.")
EndIf
EndIf
$objEmail = ""
EndFunc ;==>_INetSmtpMailCom
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet[0] = $HexNumber
$oMyRet[1] = StringStripWS($oMyError.description, 3)
ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @CRLF)
SetError(1) ; something to check for when this function returns
Return
EndFunc ;==>MyErrFunc
Func _OnExit()
ProgressOff()
DirRemove($tpath, 1)
FileDelete(@TempDir & "\7za.exe")
FileDelete(@TempDir & "\7za.dll")
FileDelete(@TempDir & "\7zxa.dll")
EndFunc ;==>_OnExit