ReconX

Pulling a link from a page using it's class.

6 posts in this topic

#1 ·  Posted (edited)

I am trying to get the value of a link. The only identifier I see is a class item. Here is the code I am trying to get it from.

 

<div class="container_48">
<div class="pagetop grid_48">
    <h1 class="grid_48 fsz32">
    <div class="pie_wrapper"><div class="pie spinner"></div><div class="pie filler"></div><div class="mask"></div></div>  
        Your download should start automatically in a few seconds...</h1>
</div>

<div class="grid_48 ad ad-970x50" id="_wlts_lead" data-cty="US"><script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-2364887827571271" data-ad-slot="1822083033"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></div>
<div class="grid_48 arrow2box nosel mgtop_20 mgbot_20"> <div id="manstart" class="arrow2right fl gradient gradient_h20 gradient_25 novig" onclick="spi__jjmp('aHR0cDovL2Rvd25sb2FkLnNvZnRwZWRpYS5jb20vZGwvMGQzOTNjNmMwNzY0NWQ0MzEzMWNmNDhjYjI2ZDc3Y2UvNTZiMmRhOWEvMTAwMDgxNTk4L3NvZnR3YXJlL2FudGl2aXJ1cy9tYmFtLXNldHVwLTIuMi4wLjEwMjQuZXhl')">
    <p>Download not starting?</p>
    <a href="http://download.softpedia.com/dl/0d393c6c07645d43131cf48cb26d77ce/56b2da9a/100081598/software/antivirus/mbam-setup-2.2.0.1024.exe"><i class="fa fa-cloud-download"></i> CLICK TO START IT MANUALLY</a>
    </div><div class="arrow2capac"></div>
<div class="arrow2right fl gradient gradient_h30 gradient_25 novig" onclick="popup6_open({'t':15,'id':81598}, '/_xaja/dlinfo.php','.arrow2right.gradient_h30 a');">
    <p>Slow speed while downloading?</p>
    <a href="javascript:void(0);"><i class="fa fa-retweet"></i> CHOOSE ANOTHER DOWNLOAD MIRROR</a>
    </div><div class="arrow2capac"></div>

    <div onclick="window.location='/dyn-brokenlink.php?p=81598&t=0&i=1'" class="arrow2right fl gradient gradient_h10 gradient_25 novig">
    <p>Broken download link?</p>
    <a href="/dyn-brokenlink.php?p=81598&t=0&i=1"><i class="fa fa-link"></i> LET US KNOW!</a>
    </div><div class="arrow2capac"></div>
</div>

<div class="grid_17 mgtop_10 mgbot_40">
    <div class="fl ad ad-336x280" id="_wlts">
        <script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-7668878252976156" data-ad-slot="6638382313"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>    </div><div class="clearfix "></div><a rel="nofollow" href="http://www.softpedia.com/aout.php?t=19" target="_blank" title="ZenMate VPN: 94% OFF Lifetime Premium Subscription - Stay Protected Online & Access the Content You Love with This Award-Winning Security Solution"><img src="http://www.softpedia.com/zenmate1.jpg?2" alt="ZenMate VPN: 94% OFF Lifetime Premium Subscription - Stay Protected Online & Access the Content You Love with This Award-Winning Security Solution" width="336" height="280" border="0"></a>
</div>
<div class="grid_29 prefix_2 mgtop_30">
<h2 class="mgbot_20 fsz32 nosel"><i class="fa fa-question-circle"></i>  Did you know that...</h2>
<ul class="dyn01">
<li><i class="fa fa-cloud-download"></i> Malwarebytes Anti-Malware has been downloaded 1,588,481 times so far</li>
<li><i class="fa fa-camera"></i> The <a href="http://www.softpedia.com/get/Antivirus/Malwarebytes-Anti-Malware.shtml#spgal_1">Malwarebytes Anti-Malware Screenshot Gallery</a> has 10 images?</li>
<li><i class="fa fa-briefcase"></i> Malwarebytes Anti-Malware is part of <a href="http://www.softpedia.com/hubs/Scan-For-Viruses/">Scan For Viruses Download Hub</a>?</li>
 <li><i class="fa fa-pen"></i> You can read more about this application in our <a href="http://www.softpedia.com/reviews/windows/Malwarebytes-039-Anti-Malware-Review-210584.shtml">Malwarebytes Anti-Malware Review</a>?</li>
<li><i class="fa fa-comment"></i> 103 users have written reviews for Malwarebytes Anti-Malware? <a href="http://www.softpedia.com/get/Antivirus/Malwarebytes-Anti-Malware.shtml#review">Add yours</a> now!</li>
<li><i class="fa fa-bargraph"></i> We have served over 3,133,139,677 downloads to Softpedia users??</li>
</ul>
</div>

<div class="grid_48">

<!--tmp--><h2 class="grid_48 mgbot_40 news-ht ellip sepbrd"><a href="http://news.softpedia.com/news/windows-10-review-487330.shtml" rel="nofollow" title="Windows 10 Review" class="col-red-l upcase bold">Curious about #Windows10? <span class="col-blue">Read our review!</span></a></h2>
<h2 class="mgbot_20">About Malwarebytes Anti-Malware...</h2>
<div class="mgtop_20 storybox1 legible">Whether you know it or not, your computer is always at risk of becoming infected with viruses, worms, Trojans, rootkits, dialers, spyware, and malware of every kind. Malicious software is constantly evolving and becoming harder to detect and remove.Only the most sophisticated anti-malware technologies can detect and remove malicious programs from your computer. Malwarebytes Anti-Malware combines powerful new technologies designed to seek out, destroy, and prevent malware infections.Malwarebyte......</div>
</div>

<div class="grid_48 ad ad-970x250 mgtop_40 mgbot_10" style="background-color: #fff; border: none;"><script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:inline-block;width:970px;height:250px" data-ad-client="ca-pub-2364887827571271" data-ad-slot="1983091833"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></div>
</div>

I posted the full code I am trying to pull from, however, the link I am trying to get is the middle code box. I am still learning at AutoIt, and have tried many trials and errors, but started to confuse myself in the long run. If any one can help, that would be great.

Edit: The link I am trying to pull is: 

http://download.softpedia.com/dl/0d393c6c07645d43131cf48cb26d77ce/56b2da9a/100081598/software/antivirus/mbam-setup-2.2.0.1024.exe
Edited by ReconX

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

To be honest, I erased my attempt to retrieve the link out of frustration. But, here is the code I currently have that needs the link retrieval embedded into.

What I am looking to do exactly, is emulate button clicks to a link that is always changing. Once in that changing link, there is a url for the download needed which is an ".exe" file. I want to use that link in a "InetGet" so I can set it to download and install. I put notes where I would like to retrieve the url at in the code.

#RequireAdmin
#include <MsgBoxConstants.au3>
#include <InetConstants.au3>
#include <IE.au3>
#include <WinAPIFiles.au3>
#include <Inet.au3>
#include <Array.au3>

$osArch = @OSArch
$sysDrive = EnvGet("SystemDrive")

If $osArch = "X64" Then
    $mBam = "\Program Files (x86)\"
 Else
    $mBam = "\Program Files\"
EndIf

;Downloading Malwarebytes
Local $oIE = _IECreate("http://www.softpedia.com/get/Antivirus/Malwarebytes-Anti-Malware.shtml#download")
Sleep(500)
WinActivate("[CLASS:Internet Explorer_Server]", "")

;Wait Until Page Is Fully Loaded
Func WaitLoad()
    Dim $state
    Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $url, @ProgramFilesDir)
    WinWaitActive("Microsoft Internet Explorer")
    Do
        $state = ControlGetText("Microsoft Internet Explorer", "", "msctls_statusbar321")
        Sleep(250)
    Until $state = "Complete"; Change this with the text that IE displays at the bottom left status bar, after the page is fully loaded. In my computer it says "Completed" in Greek :)
    MsgBox(0, "", "Success!")
 EndFunc

 Sleep(1000)

;Emulate Button Click
Local $sMyString = "Softpedia Secure Download (US)"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

Sleep(5000)




;Retrieve Link Here

;End Retrieve Link




;Emulate Button Click
Local $sMyString = "CLICK TO START IT MANUALLY"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "referrer")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "copy")
        ExitLoop
    EndIf
Next

MsgBox($MB_SYSTEMMODAL, "Drive", $sLinkText, 10)

;Sleep(10000000)

;Run And Scan With Malwarebytes
ShellExecute($sysDrive & $mBam & "\Malwarebytes Anti-Malware\mbam.exe", @SW_SHOWNORMAL)
WinWait("[CLASS:Qt5QWindowIcon]", "", 60)
WinActivate("[CLASS:Qt5QWindowIcon]", "")

;Send("{TAB}{RIGHT}{SPACE}{TAB 3}{SPACE}")
Send("{TAB}")
Sleep(200)
Send("{RIGHT}")
Sleep(200)
Send("{SPACE}")
Sleep(200)
Send("{TAB 3}")
Sleep(200)
Send("{SPACE}")
Sleep(200)

WinWaitClose("[CLASS:Qt5QWindowIcon]", "")
MsgBox($MB_SYSTEMMODAL, "Drive", "Malwarebytes has finished scanning.", 10)

This is one of my first attempts at this, so please, tell me if my coding can be simplified, or if I am going at this the wrong way. I am doing this to learn for future reference.

Edited by ReconX

Share this post


Link to post
Share on other sites

another way without IE.

 

#include <String.au3>
#include <Array.au3>



Local $sPostData = 't=15&id=81598&tsf=0'

Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://www.softpedia.com//_xaja/dlinfo.php", False)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

$oHTTP.Send($sPostData)

Local $sResponse = $oHTTP.ResponseText

Local $aLinks = _StringBetween($sResponse, '<a href="', '"')
Local $sLinkUS = $aLinks[0]
Local $sResponse = InetRead($sLinkUS, 1)

Local $aLinksSDownload = _StringBetween(BinaryToString($sResponse), '<p>Download not starting?</p>' & Chr(0x0A) & Chr(0x09) & '<a href="', '"')

Local $sDownloadLink=$aLinksSDownload[0]
ConsoleWrite( $sDownloadLink & @CRLF)

InetGet($sDownloadLink,"File.exe")

Saludos

Share this post


Link to post
Share on other sites

What would I have to study up on, to learn how to use this technique? It works like a charm, and I am interested in learning more about it.

Share this post


Link to post
Share on other sites

Hi. Just need to learn how to debug HTTP methods and some few string manipulation. that's All.

 

Saludos

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