Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
peak debt
Mar 11, 2001
b& :(
Nap Ghost
Powershell can do that too with Invoke-Webrequest http://technet.microsoft.com/en-us/library/hh849901.aspx

The general procedure is that you launch Fiddler in the background, do a manual login, then check the Fiddler capture for the important GET and POST requests.
You can then duplicate them with the web requests, using the -SessionVariable argument to remember the cookies.

Edit: As an example this is a script I use to check our 20+ scanners for deleted user accounts:

code:
<#
 # Logs on to the web interface of a Canon 2525 copier, gets the list of users configured
 # for scanning and checks whether their AD accounts still exist
 #>
 
$ip = "10.0.0.0"

# Log on to the web interface as administrator
$login = Invoke-WebRequest "http://$ip/_top.html" -SessionVariable copier
$login.Forms[0].Fields.user_name = "1"
$login.Forms[0].Fields.pwd = "2"
$login.Forms[0].Fields.login_mode = "admin"
$login.Forms[0].Fields.lang = "0"
Invoke-WebRequest "http://$ip/login.cgi" -WebSession $copier -Method Post -Body $login > $null

# Copy the cookies to the root path to make the login work properly
$copier.Cookies.Add("http://$ip/", $copier.Cookies.GetCookies("http://$ip/login.cgi"))

# Enter the address book password
Invoke-WebRequest "http://$ip/_adrs_book.html" -WebSession $copier -Method Post -Body @{LOCK_PWD='3'} > $null

$done = $false
# Iterate through the address book pages
for ($i=1; -not $done; $i += 12) {
    $mainPage = Invoke-WebRequest "http://$ip/adrs_low.html" -Method Post -Body @{DN="$i"} -WebSession $copier

    # Parse for the email address with a regexp
    $emails = $mainPage.RawContent | Select-String -Pattern "E-mail\<\/td\>\<td\>(.*@.*\...)\<\/td\>" -AllMatches
    if ($emails.Matches.length -ne 0) {
        $emails.Matches | % {
            $email = $_.Groups[1].Value

            # Search for the user in AD by primary email address
            $user = Get-ADUser -Filter {mail -eq $email}
            if ($user -eq $null) {
                # If the user doesn't exist, print a warning in red color
                Write-Host "$email" -ForegroundColor red
            }
            $user.Name
        }
    } else {
        # If we just parsed a page without a single configured account, assume that we are done
        $done = $true
    }
}

peak debt fucked around with this message at 10:01 on Jun 13, 2014

Adbot
ADBOT LOVES YOU

  • Locked thread