Advertisement
Guest User

Facebook spider/scraper

a guest
Apr 27th, 2018
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.42 KB | None | 0 0
  1. #!/bin/bash
  2. ##########################
  3. # Facebook DataDumper Version 1.1
  4. # This script will dump & parse raw HTML for users "friends list" and "General profile info",
  5. # This can be expanded following the same steps below(I didnt because of a moral issue)
  6. # During the development/testing, we were able to pull 300 accounts in a matter of 300+ account in under 60 Seconds.
  7. #
  8. # - Weaponized Deployment
  9. #   - Deploy nodes in AWS/GOOGLE/SEA (They are going to get burnt fast!)
  10. #   - Fake accounts for the cookies (Account are going to be burnt fast, maybe a bunch of accounts!)
  11. #   - Add 5+ random users "ID" to the profiles table, run the vacuum
  12. #
  13. # By jmp2fail
  14. #
  15. ###################################
  16. user="hd"
  17. password="pass"
  18. host="127.0.0.1"
  19. # Get some basic info to demonstrate the issue
  20. while :
  21. do
  22. sleep $[ ( $RANDOM % 10 ) + 1 ]s
  23. Profiles_to_pull=$(mysql -u $user -p$password -h $host FB_Testdata --skip-column-names -e "SELECT Profile_ID FROM Profiles WHERE pulled is NULL LIMIT 15")
  24. for Profile_ID in $Profiles_to_pull; do
  25. Root_ID="$(echo $Profile_ID)"
  26. echo $Profile_ID
  27. Root_ID="$(echo $Profile_ID)"
  28. sleep $[ ( $RANDOM % 15 ) + 1 ]s
  29. # Pull the friends
  30. Profile_Friends_List="$(wget --load-cookies=cookies.txt -U "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)" -O - https://www.facebook.com/$Profile_ID/friends | sed 's/testid/\n/g' | ggrep -o -P '(?<=uiProfileBlockContent\"\>\<div\ class\=\"\_6a\"\>\<div\ class\=\"\_6a\ \_6b\"\ style\=\"height\:100px\"\>\<\/div\>\<div\ class\=\"\_6a\ \_6b\"\>\<div\ class\=\"fsl\ fwb\ fcb\"\>\<a\ href\=\"https\:\/\/www\.facebook\.com\/).*(?=\?fref\=pb\&amp\;hc\_location\=friends\_tab\")')"
  31. for Profile_ID_New in $Profile_Friends_List;
  32. do
  33. notnew=$(mysql -u $user -p$password -h $host FB_Testdata --skip-column-names -e "SELECT Profile_ID FROM Profiles WHERE Profile_ID = '$Profile_ID_New'")
  34. echo $notnew
  35. if [ -z "$notnew" ];
  36. then
  37. echo "friends"
  38. mysql -u $user -p$password -h $host FB_Testdata -e "insert into Profiles (Profile_ID,Root_ID) values ('$Profile_ID_New' , '$Root_ID')"
  39. fi
  40. done
  41. # Pull the profile
  42. notnew=$(mysql -u $user -p$password -h $host --skip-column-names FB_Testdata -e "SELECT Profile_ID FROM Profiles_data WHERE Profile_ID = '$Profile_ID'")
  43. if [ -z "$notnew" ];
  44. then
  45. echo "profle dump"
  46. sleep $[ ( $RANDOM % 15 ) + 1 ]s
  47. Profile_Info="$(wget --load-cookies=cookies.txt -U "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)" -O - https://www.facebook.com/$Profile_ID/about?section=contact-info)"
  48. Profile_Gender="$(echo $Profile_Info | ggrep -o -P 'Gender.{0,90}' | sed 's/Gender.*>/ /g')"
  49. Profile_Orientation="$(echo $Profile_Info | ggrep -o -P 'Interested.{0,92}' | sed 's/Interested.*>//g')"
  50. Profile_DOB="$(echo $Profile_Info | ggrep -o -P 'Birthday.{0,103}' | sed 's/Birthday.*2iem">//g' | sed 's/<.*//g')"
  51. Profile_Religious="$(echo $Profile_Info | ggrep -o -P 'Religious.{0,335}' | ggrep -o -P 'Religious.{0,335}' | sed 's/Religious.*"1">//g' )"
  52. echo $Profile_Gender
  53. echo $Profile_Orientation
  54. echo $Profile_DOB
  55. echo $Profile_LivesIn
  56. mysql -u $user -p$password -h $host FB_Testdata -e "insert into Profiles_data (Profile_ID,Profile_Gender,Profile_DOB,Profile_Orientation,Profile_Religious_Views) values ('$Profile_ID', '$Profile_Gender', '$Profile_DOB', '$Profile_Orientation', '$Profile_Religious')"
  57. mysql -u $user -p$password -h $host FB_Testdata -e "UPDATE Profiles SET Pulled = '1' WHERE Profile_ID = '$Profile_ID'"
  58. fi
  59. done
  60. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement