Skip to content

Instantly share code, notes, and snippets.

@potatoqualitee
Last active August 4, 2022 14:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save potatoqualitee/9aef3fdd9b73e399280a to your computer and use it in GitHub Desktop.
Save potatoqualitee/9aef3fdd9b73e399280a to your computer and use it in GitHub Desktop.
login to facebook mobile using powershell
$url = "https://m.facebook.com/login.php"
$webrequest = Invoke-WebRequest -Uri $url -SessionVariable session
# The cookies aren't always set properly. Here, we'll force set them
$setcookies = $webrequest.Headers["Set-Cookie"].Split(";").Trim()
foreach ($setcookie in $setcookies) {
$cookie = New-Object System.Net.Cookie
$cookie.Name = $setcookie.split("=")[0]
$cookie.Value = $setcookie.split("=")[1]
$cookie.Domain = ".facebook.com"
if ($cookie.name -ne "Expires") {
$session.Cookies.Add($cookie)
$cookie
}
}
<#
$cookies = $session.Cookies.GetCookies($url)
foreach ($cookie in $cookies) {
Write-Host "$($cookie.name) = $($cookie.value)"
}
#>
$credential = Get-Credential # or Import-CliXml cred.xml
$form = $webrequest.Forms[0]
$form.Fields["email"] = $credential.GetNetworkCredential().username
$form.Fields["pass"] = $credential.GetNetworkCredential().password
$login = Invoke-WebRequest -Uri $url -WebSession $session -Method POST -Body $form.Fields
$response = Invoke-WebRequest -Uri "https://m.facebook.com/119812241410296" -WebSession $session
$response.content > test.html
.\test.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment