QQGroup Analyzer

From NAT, 5 Years ago, written in Bash, viewed 801 times.
URL https://code.nat.moe/view/7ba34d3f Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. bkn=""
  4. COOKIE="Cookie: p_skey=...; p_uin=...; pt4_token=...; ts_last=...; ts_refer=...; ts_uid=...; RK=...; pgv_info=ssid=...; pgv_pvid=...; ......"
  5.  
  6. # You can get those using brup :)
  7.  
  8. USERS_JSON_URL="http://qun.qq.com/cgi-bin/qun_mgr/search_group_members"
  9. USERS_GET_PAYLOAD="gc=_GID_&st=0&end=1000&sort=0&bkn=$bkn"
  10.  
  11. GLIST_JSON_URL="http://qun.qq.com/cgi-bin/qun_mgr/get_group_list"
  12. GLIST_GET_PAYLOAD="bkn=$bkn"
  13.  
  14. # usage: getUsersList <gid>
  15. function getUsersList {
  16.         curl $USERS_JSON_URL --data "$(echo $USERS_GET_PAYLOAD | sed -e "s/_GID_/$1/")" -H "$COOKIE" 2> /dev/null | sed -e 's/{"card":/§{"card":/g'|tr '§' '\n'|awk -F\" '{print $33 "|" $4 "|" $22 }' | sed -e 's/|:/\|/g; s/}\,//g; s/://g; s/}\],//g; 1d;'
  17. }
  18.  
  19. function getGroupList {
  20.         curl $GLIST_JSON_URL --data $GLIST_GET_PAYLOAD -H "$COOKIE" 2> /dev/null | sed 's/"gc"/§"gc"/g' | tr '§' '\n' | awk -F':' '{print $2 "|" $3}' | sed -e 's/,"gn"//g; s/","owner"//g; s/"//g; 1d;'
  21. }
  22.  
  23. function getAllUsers {
  24.         getGroupList > groups.txt
  25.         local groups=$(cat groups.txt)
  26.         for group in $groups
  27.         do
  28.                 local gid=$(echo $group|awk -F"|" '{print $1}')
  29.                 echo -n "[$(date)] Getting $group... "
  30.                 getUsersList $group > group-$gid.txt
  31.                 echo "done"
  32.                 sleep 1
  33.         done
  34. }
  35.  
  36. function getUsersListFromList {
  37.         cat group-*.txt | awk -F"|" '{print $1}' | sort | uniq -d
  38. }
  39.  
  40.  
  41. # usage: findJoinedGroupByID <uid>
  42. function findJoinedGroupByID {
  43.         grep -lir "$1" . | grep group- | awk -F"group-|.txt" '{print $2}'
  44. }
  45.  
  46. function getGroupNameByID {
  47.         cat groups.txt | grep $1 | awk -F"|" '{print $2}' | sed -e 's/&nbsp;/ /g;'
  48. }
  49.  
  50. # usage: ListJoinedGroupByID [uid]
  51. function ListJoinedGroupByID {
  52.         local users=$(getUsersListFromList)
  53.         for user in $users
  54.         do
  55.                 [[ -z $1 || $1 == $user ]] && {
  56.                         echo "User: $(getUsernameByID $user) ($user)"
  57.                         echo "-------------------------------------------------------------------------------"
  58.                         local this_joined=$(findJoinedGroupByID $user)
  59.                         for this_group in $this_joined
  60.                         do
  61.                                 echo "$(getGroupNameByID $this_group) ($this_group) as $(getUsernameInGroupByID $this_group $user)"
  62.                         done
  63.                         echo "-------------------------------------------------------------------------------"
  64.                         echo
  65.                 }
  66.         done
  67. }
  68.  
  69. function getUsernameByID {
  70.         cat group-*.txt | grep $1 | tail -n1 | awk -F "|" '{print $3}' | sed -e 's/&nbsp;/ /g;'
  71. }
  72.  
  73. function getUsernameInGroupByID {
  74.         local name=$(cat group-$1.txt | grep $2 | awk -F "|" '{print $2}')
  75.         [[ -z $name ]] && name=$(cat group-$1.txt | grep $2 | awk -F "|" '{print $3}')
  76.         echo $name | sed -e 's/&nbsp;/ /g;'
  77. }
  78.  
  79. $*
  80.  

Replies to QQGroup Analyzer rss

Title Name Language When
Re: QQGroup Analyzer NAT bash 5 Years ago.

Reply to "QQGroup Analyzer"

Here you can reply to the paste above

captcha