General discussion

Locked

readout ip-addresses to a single txt file

By T8pMusic ·
Hello,

Im working on a script that will read ip-addresses from *.eml files and to put them in a single txt file so that i only have to copy/paste them in the spam/blacklisted server.

What i have so far;

the script itself (spam_ip.vbs)

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set folder = objFSO.GetFolder("z:\test\")

for each file in folder.Files

if lcase(objFSO.getExtensionName(file.path))="eml" then

Set objFile = objFSO.OpenTextFile(file.path, ForReading)


strSearchString = objFile.ReadAll
objFile.Close

Set objRegEx = CreateObject("VBScript.RegExp")

objRegEx.Global = True
objRegEx.Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"

Set colMatches = objRegEx.Execute(strSearchString)

For Each strMatch in colMatches
If Left(strMatch.Value, 3) <> "255" Then
Wscript.Echo strMatch.Value
End If
Next

If colMatches.Count > 0 Then
For Each strMatch in colMatches
Wscript.Echo strMatch.Value
Next
End If
End If

-------

to get it in a file i use a bat file spam.bat

cscript spam_ip.vbs > spam.txt

------

The problem that im having is that ill get an error when running the vb script (loop detected) and i can't figure out why.

Can someone help with this ?

Fred

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Some thoughts

by TobiF In reply to readout ip-addresses to a ...

1. Next time you have a question, why not post it as a question, rather than discussion?

2. When I copied your code to Notepad and indented after each for and if (and went back one step for each next or endif) I got a mismatch in the outmost for-loop.
Try to replace the last "End If" with "Next"

3. If it is valid in VBS, why not use the notation "Next <i>variable</i>? Or at least use indentation and comments, especially for "next" and "endif".

4. I hope you're aware that most of all, you're going to blacklist your own mail server (as well as gmail, yahoo etc.)? And also: Spammers often insert additional fake tracing rows, where they may, from time to time, indicate an ip-address that you wouldn't like to block.
Oh, somewhere you need to filter private addresses... 192.168.. 10... 172.16.. etc.

Good luck!

Back to Networks Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums