mozilla:abpxfiles:vbs:hwsmaker
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
mozilla:abpxfiles:vbs:hwsmaker [2013/08/08 12:19] – gfsadministrator | mozilla:abpxfiles:vbs:hwsmaker [2017/01/30 10:36] (current) – gfsadministrator | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== HWS Maker ====== | + | {{ : |
- | Work in progress | + | >Righe di debug sparse un po' ovunque, sicuramente una marea di errori dovuti alla mia inesperienza e auto-formazione sulla programmazione |
+ | |||
+ | Vedi l' | ||
+ | Se stai cercando "suo fratello" | ||
===== Sourcecode ===== | ===== Sourcecode ===== | ||
In versione 0.1 già perfettamente funzionante, | In versione 0.1 già perfettamente funzionante, | ||
- | <file vb HWS-Maker_0.1.vbs> | + | Facendo clic sul nome dello script "HWS-Maker_XX.vbs" |
- | ' ABP X FILES HWS Maker 0.1 | + | |
- | ' GSolone - Ultima modifica: 20130808 | + | |
- | ' | + | |
- | ' Lo script scarica la lista filtri più aggiornata disponibile su MalwareDomainList.com e la modifica per renderla integrabile all' | + | |
- | ' | + | |
- | ' STORICO MODIFICHE | + | |
- | ' - | + | |
- | ' | + | |
- | ' Sviluppo: Giovanni F. -Gioxx- Solone (dev@gfsolone.com) | + | |
- | ' Testato su: Windows 7 Pro Sp1 | + | |
- | ' | + | |
- | ' LISTA HOST UTILIZZATA | + | |
- | HTTPDownload | + | |
- | + | ||
- | ' Non toccare nulla oltre questa riga! | + | |
- | ' DO NOT touch anything below this line! | + | |
- | + | ||
- | Sub HTTPDownload(myURL) | + | |
- | ' Variables and constants definition | + | |
- | Dim i, objFile, objFSO, objHTTP, strFile, strMsg | + | |
- | Dim objWMIService, | + | |
- | Const ForReading = 1, ForWriting = 2, ForAppending = 8 | + | |
- | + | ||
- | ' Date and time | + | |
- | strComputer = " | + | |
- | Set objWMIService = GetObject(" | + | |
- | Set colItems = objWMIService.ExecQuery(" | + | |
- | For Each objItem in colItems | + | |
- | dtmLocalTime = objItem.LocalDateTime | + | |
- | dtmMonth = Mid(dtmLocalTime, | + | |
- | dtmDay = Mid(dtmLocalTime, | + | |
- | dtmYear = Left(dtmLocalTime, | + | |
- | dtmHour = Mid(dtmLocalTime, | + | |
- | dtmMinutes = Mid(dtmLocalTime, | + | |
- | dtmSeconds = Mid(dtmLocalTime, | + | |
- | Next | + | |
- | update = dtmYear & dtmMonth & dtmDay & dtmHour & dtmMinutes | + | |
- | lastmodified = dtmDay & " | + | |
- | ' debug Wscript.Echo update | + | |
- | + | ||
- | ' | + | |
- | Set objFSO = CreateObject( " | + | |
- | + | ||
- | ' | + | |
- | Set objShell = CreateObject(" | + | |
- | Set objProcess = objShell.Environment(" | + | |
- | Set WshShell = WScript.CreateObject(" | + | |
- | strApplicationData = WshShell.ExpandEnvironmentStrings(" | + | |
- | | + | |
- | + | ||
- | ' | + | |
- | Set objHTTP = CreateObject( " | + | |
- | + | ||
- | ' | + | |
- | | + | |
- | | + | |
- | + | ||
- | if LenB( objHTTP.ResponseBody ) < 500 Then | + | |
- | MsgBox " | + | |
- | Exit Sub | + | |
- | End If | + | |
- | + | ||
- | ' Create or open the target file | + | |
- | Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True ) | + | |
- | + | ||
- | ' | + | |
- | For i = 1 To LenB( objHTTP.ResponseBody ) | + | |
- | | + | |
- | | + | |
- | + | ||
- | ' | + | |
- | | + | |
- | + | ||
- | ' Remove line 1 to 6, header of MalwareDomainList.com Hosts List | + | |
- | For i = 1 To 6 | + | |
- | DeleteLine strFile, "", | + | |
- | | + | |
- | + | ||
- | ' 1- Find and remove 127.0.0.1 from each line | + | |
- | Set objFSO = CreateObject(" | + | |
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | strText = objFile.ReadAll | + | |
- | objFile.Close | + | |
- | strNewText = Replace(strText, | + | |
- | + | ||
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | objFile.WriteLine strNewText | + | |
- | objFile.Close | + | |
- | + | ||
- | ' 2- Append "## | + | |
- | Set objFSO = CreateObject(" | + | |
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | Set tmpFile= objFSO.OpenTextFile(strFile & " | + | |
- | Do While Not objFile.AtEndofStream | + | |
- | url = objFile.ReadLine | + | |
- | url = url & "## | + | |
- | tmpFile.WriteLine url | + | |
- | Loop | + | |
- | objFile.Close | + | |
- | tmpFile.Close | + | |
- | objFSO.DeleteFile(strFile) | + | |
- | objFSO.MoveFile strFile&" | + | |
- | + | ||
- | ' 3- Then remove empty lines at the end of file! | + | |
- | Set objFSO = CreateObject(" | + | |
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | Do Until objFile.AtEndOfStream | + | |
- | strLine = objFile.Readline | + | |
- | strLine = Trim(strLine) | + | |
- | If Len(strLine) > 0 Then | + | |
- | strNewContents = strNewContents & strLine & vbCrLf | + | |
- | End If | + | |
- | Loop | + | |
- | objFile.Close | + | |
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | objFile.Write strNewContents | + | |
- | objFile.Close | + | |
- | + | ||
- | ' Add list header (ABP X Files HWS) | + | |
- | Set objFSO = CreateObject(" | + | |
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | strContents = objFile.ReadAll | + | |
- | objFile.Close | + | |
- | + | ||
- | strFirstLine = " | + | |
- | strNewContents = strFirstLine & vbCrLf & strContents | + | |
- | + | ||
- | Set objFile = objFSO.OpenTextFile(strFile, | + | |
- | objFile.WriteLine strNewContents | + | |
- | objFile.Close | + | |
- | + | ||
- | ' Open the file (verification process) | + | |
- | CreateObject(" | + | |
- | + | ||
- | End Sub | + | |
- | + | ||
- | Sub Run(ByVal sFile) | + | |
- | ' Variables definition | + | |
- | Dim shell | + | |
- | + | ||
- | Set shell = CreateObject( " | + | |
- | shell.Run Chr(34) & sFile & Chr(34), 1, false | + | |
- | Set shell = Nothing | + | |
- | End Sub | + | |
- | Sub DeleteLine(strFile, strKey, LineNumber, CheckCase) | + | Ho spostato lo script su Gist, disponibile ora all'URL https://gist.github.com/gioxx/5f2835af08b3f2df61d76af56d877bd4# |
- | 'Use strFile = "c:\file.txt" | + | |
- | 'Use strKey = "John Doe" | + | |
- | 'Use strKey = "" | + | |
- | 'Use LineNumber = " | + | |
- | 'Use LineNumber = " | + | |
- | 'Use CheckCase = " | + | |
- | 'Use CheckCase = " | + | |
- | Const ForReading=1: | + | |
- | Dim objFSO, | + | |
- | Set objFSO=CreateObject(" | + | |
- | Set objFile=objFSO.OpenTextFile(strFile, | + | |
- | Do Until objFile.AtEndOfStream | + | |
- | | + | |
- | If CheckCase=0 then strLineCase=ucase(strLine): | + | |
- | If LineNumber=objFile.Line-1 or LineNumber=0 then | + | |
- | If instr(strLine, | + | |
- | | + | |
- | Else | + | |
- | | + | |
- | End If | + | |
- | | + | |
- | strNewFile=strNewFile& | + | |
- | End If | + | |
- | Loop | + | |
- | objFile.Close | + | |
- | Set objFSO=CreateObject(" | + | |
- | Set objFile=objFSO.OpenTextFile(strFile, | + | |
- | objFile.Write strNewFile | + | |
- | objFile.Close | + | |
- | End Sub | + | |
- | </file> | + |
mozilla/abpxfiles/vbs/hwsmaker.1375957194.txt.gz · Last modified: 2013/08/08 12:19 by gfsadministrator