Advertisement
Guest User

Möröbbs-putsi

a guest
Oct 18th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. function Get-Token
  2. {
  3. param($editURL)
  4.  
  5. $lines = $editURL.content.Split("\n")
  6.  
  7. foreach($line in $lines)
  8. {
  9. if($line -match "value=`"$userID,")
  10. {
  11. $token = $line.Split("`"")[2]
  12. break
  13. }
  14. }
  15.  
  16. return $token
  17. }
  18.  
  19. # user information
  20. $username = "oma sähköposti"
  21. $password = "oma salasana"
  22. $userID = "oma userid"
  23. $site = "http://murobbs.muropaketti.com/"
  24.  
  25. # body for login
  26. $body = @{
  27. login = $username
  28. password = $password
  29. cookie_check = $true
  30. redirect = "/"
  31. _xfToken = $null
  32. }
  33.  
  34. # login and get session
  35. $login = Invoke-RestMethod -Method Post -Uri "$site/login/login" -SessionVariable session -Body $body
  36.  
  37. # get first 20 posts from all post view
  38. $threadsPage = Invoke-WebRequest -Uri "$site/search/member?user_id=$userID" -WebSession $session
  39.  
  40. # get search ID (this ID changes every time)
  41. $searchPath = $threadsPage.BaseResponse.ResponseUri.LocalPath.Substring(1, $threadsPage.BaseResponse.ResponseUri.LocalPath.Length-2)
  42.  
  43. # get post ID's from the first page
  44. $postsIDs = ($threadsPage.ParsedHtml.getElementsByTagName('li') | where {$_.id -like "post-*"}).id -replace "post-",""
  45.  
  46. # go through each page and append the IDs to the postsIDs array
  47. foreach($i in 2..10)
  48. {
  49. $threadsPage = Invoke-WebRequest -Uri "$site$searchPath/?page=$i" -WebSession $session
  50. $postsIDs += ($threadsPage.ParsedHtml.getElementsByTagName('li') | where {$_.id -like "post-*"}).id -replace "post-",""
  51. }
  52.  
  53. # go through all postIDs
  54. foreach($postID in $postsIDs)
  55. {
  56. # url content for token
  57. $editURL = Invoke-WebRequest -Uri "$site/posts/$postID" -WebSession $session
  58.  
  59. # get token
  60. $token = Get-Token -editURL $editURL
  61.  
  62. # edit post data
  63. $data = @{
  64. "message_html" = "poisto"
  65. "_xfToken" = $token
  66. }
  67.  
  68. # edit post
  69. $res = Invoke-WebRequest -Uri "$site/posts/$postID/save" -WebSession $session -Method Post -Body $data
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement