Jump to content
Sign in to follow this  
0_00_0

Messy code needs help!

Recommended Posts

0_00_0

Hey guys I`m trying to use StringRegExp() to look for proxies in a text file. The format of the text files are in jumbled HTML and I want to just pick out the proxies from it. The problem is that it if it`s given a string such as abc123.123.123.123:8080abc, it will not pick out the abc`s in front and after. I`m going to try and stick a couple breaks in there to see if i can figure it out, but maybe someone can help me out with a more specific filter. It finds the proxies, but with any text directly attached to it.

I thought this would work

Func proxyLeech($proxyFileName)
    $proxyFile = FileOpen($proxyFileName, 0)
    $currentLine = FileReadLine($proxyFile)
    while not $currentLine = ""
        while StringLen($currentLine) > 0
            $tempLine = $currentLine
            While StringLen($tempLine) > 0
                GUICtrlSetData($hOutput, $tempLine)
                if StringRegExp ($tempLine, "[0-9].[0-9].[0-9].[0-9]:[0-9]", 0) Then
                    MsgBox(0, "Found Proxy", $currentLine & @CRLF & $tempLine)
                                        Exitloop(2)
                EndIf
                $tempLine = StringTrimRight($tempLine, 1)
            WEnd
            $currentLine = StringTrimLeft ($currentLine, 1)
        WEnd
        $currentLine = FileReadLine($proxyFile)
    WEnd
    
    FileClose($proxyFile)
EndFunc

edit: threw an exitloop(2) in there so it doesn`t find the same proxy twice

edit2: here is an example proxy file, I am just getting the raw html using _INetGetSource(). Unless there is a better way of reading it...

<tr><td>128.112.139.73:3124</td><td>CoDeen/PlanetLab? </td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3127</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3128</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3124</td><td>Planetlab/CoDeeN proxy server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3127</td><td>CoDeen/PlanetLab? server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3128</td><td>CoDeen/PlanetLab? proxy server</td><td>13 minutes ago</td><td>United States</td></tr></table>
          <div style="text-align:center; margin-top:10px; margin-bottom: 10px">
Edited by 0_00_0

Share this post


Link to post
Share on other sites
smashly

An example proxy txt file may help others to optimize your StringRegExp() pattern.

Share this post


Link to post
Share on other sites
0_00_0

added an example input!

Share this post


Link to post
Share on other sites
Valuater

This works..

Dim $ndata, $Data = "<tr><td>128.112.139.73:3124</td><td>CoDeen/PlanetLab? </td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3127</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3128</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3124</td><td>Planetlab/CoDeeN proxy server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3127</td><td>CoDeen/PlanetLab? server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3128</td><td>CoDeen/PlanetLab? proxy server</td><td>13 minutes ago</td><td>United States</td></tr></table>" & _
        '<div style="text-align:center; margin-top:10px; margin-bottom: 10px">'
$Data = StringSplit($Data, ".")


For $x = 1 To $Data[0] - 1
    If StringLen($Data[$x]) = 3 Then
        $ndata &= StringRight($Data[$x - 1], 3) & "." & $Data[$x] & "." & $Data[$x + 1] & @CRLF
        $x += 1
    EndIf
Next

MsgBox(4096, "Info", $ndata)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
smashly

This works..

No it doesn't, it doesn't show the last .xxx

But this does...

#include <Array.au3>; only needed for _ArrayDisplay()

Dim $sData, $aData = "<tr><td>128.112.139.73:3124</td><td>CoDeen/PlanetLab? </td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3127</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3128</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3124</td><td>Planetlab/CoDeeN proxy server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3127</td><td>CoDeen/PlanetLab? server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3128</td><td>CoDeen/PlanetLab? proxy server</td><td>13 minutes ago</td><td>United States</td></tr></table>" & _
        '<div style="text-align:center; margin-top:10px; margin-bottom: 10px">'
$aData = StringRegExp($aData, "\d+\.\d+\.\d+\.\d+", 3)
If @error Then Exit
For $i = 0 To UBound($aData) -1
    If Not StringInStr($sData, $aData[$i]) Then $sData &= $aData[$i] & Chr(0)
Next
$aData = StringSplit(StringTrimRight($sData, 1), Chr(0))
_ArrayDisplay($aData)oÝ÷ ØêÚºÚ"µÍ[H    ÌÍÜÑ]K  ÌÍØQ]HH  ][ÝÉÝÝÉÝ  ÝÌLLLLÎKÌÎÌL  ËÝ    ÝÉÝ  ÝÐÛÑY[Ô[]XÈ   ËÝ    ÝÉÝ  ÝÌLÈZ[]ÈYÛÉËÝ   ÝÉÝ  ÝÕ[]YÝ]ÉËÝ    ÝÉËÝÝÉÝÝÉÝ    ÝÌLLLLÎKÌÎÌLÉËÝ    ÝÉÝ  ÝÐÛÑY[Ô[]XÈÞIËÝ    ÝÉÝ  ÝÌLÈZ[]ÈYÛÉËÝ   ÝÉÝ  ÝÕ[]YÝ]ÉËÝ    ÝÉËÝÝÉÝÝÉÝ    ÝÌLLLLÎKÌÎÌL  ËÝ    ÝÉÝ  ÝÐÛÑY[Ô[]XÈÞIËÝ    ÝÉÝ  ÝÌLÈZ[]ÈYÛÉËÝ   ÝÉÝ  ÝÕ[]YÝ]ÉËÝ    ÝÉËÝÝÉÝÝÉÝ    ÝÌLLLLÎKÌL  ËÝ    ÝÉÝ  ÝÔ[]XÐÛÑYSÞHÙËÝ    ÝÉÝ  ÝÌLÈZ[]ÈYÛÉËÝ   ÝÉÝ  ÝÕ[]YÝ]ÉËÝ    ÝÉËÝÝÉÝÝÉÝ    ÝÌLLLLÎKÌLÉËÝ    ÝÉÝ  ÝÐÛÑY[Ô[]XÈÙËÝ ÝÉÝ  ÝÌLÈZ[]ÈYÛÉËÝ   ÝÉÝ  ÝÕ[]YÝ]ÉËÝ    ÝÉËÝÝÉÝÝÉÝ    ÝÌLLLLÎKÌL  ËÝ    ÝÉÝ  ÝÐÛÑY[Ô[]XÈÞHÙËÝ  ÝÉÝ  ÝÌLÈZ[]ÈYÛÉËÝ   ÝÉÝ  ÝÕ[]YÝ]ÉËÝ    ÝÉËÝÝÉËÝXIÝÉ][ÝÈ    [È   ÌÎNÉÙ]Ý[OI][ÝÝ^X[YÛÙ[ÈXÚ[]ÜLÈXÚ[XÝÛNL   ][ÝÉÝÉÌÎNÂÌÍØQ]HHÝ[ÔYÑ^
    ÌÍØQ]K   ][ÝÉÌLÙ
ÉÌLËÌLÙ
ÉÌLËÌLÙ
ÉÌLËÌLÙ
É][ÝËÊBYÜ[^]Ü ÌÍÚHHÈPÝ[
    ÌÍØQ]JHLBRYÝÝ[Ò[Ý    ÌÍÜÑ]K  ÌÍØQ]VÉÌÍÚWJH[   ÌÍÜÑ]H  [ÏH    ÌÍØQ]VÉÌÍÚWH [È^ÙÐÞ
M   ][ÝÒ[É][ÝË ÌÍÜÑ]J
Edited by smashly

Share this post


Link to post
Share on other sites
Valuater

BFD MF

Dim $ndata, $Data = "<tr><td>128.112.139.73:3124</td><td>CoDeen/PlanetLab? </td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3127</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.73:3128</td><td>CoDeen/PlanetLab? proxy</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3124</td><td>Planetlab/CoDeeN proxy server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3127</td><td>CoDeen/PlanetLab? server</td><td>13 minutes ago</td><td>United States</td></tr><tr><td>128.112.139.80:3128</td><td>CoDeen/PlanetLab? proxy server</td><td>13 minutes ago</td><td>United States</td></tr></table>" & _
        '<div style="text-align:center; margin-top:10px; margin-bottom: 10px">'
$Data = StringSplit($Data, ".")


For $x = 1 To $Data[0] - 1
    If StringLen($Data[$x]) = 3 Then
        $ndata &= StringRight($Data[$x - 1], 3) & "." & $Data[$x] & "." & $Data[$x + 1] & "." & StringLeft($Data[$x + 2], 2)  & @CRLF
        $x += 1
    EndIf
Next

MsgBox(4096, "Info", $ndata)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×