#!/bin/bash bkn="" COOKIE="Cookie: p_skey=...; p_uin=...; pt4_token=...; ts_last=...; ts_refer=...; ts_uid=...; RK=...; pgv_info=ssid=...; pgv_pvid=...; ......" # You can get those using brup :) USERS_JSON_URL="http://qun.qq.com/cgi-bin/qun_mgr/search_group_members" USERS_GET_PAYLOAD="gc=_GID_&st=0&end=1000&sort=0&bkn=$bkn" GLIST_JSON_URL="http://qun.qq.com/cgi-bin/qun_mgr/get_group_list" GLIST_GET_PAYLOAD="bkn=$bkn" # usage: getUsersList function getUsersList { 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;' } function getGroupList { 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;' } function getAllUsers { getGroupList > groups.txt local groups=$(cat groups.txt) for group in $groups do local gid=$(echo $group|awk -F"|" '{print $1}') echo -n "[$(date)] Getting $group... " getUsersList $group > group-$gid.txt echo "done" sleep 1 done } function getUsersListFromList { cat group-*.txt | awk -F"|" '{print $1}' | sort | uniq -d } # usage: findJoinedGroupByID function findJoinedGroupByID { grep -lir "$1" . | grep group- | awk -F"group-|.txt" '{print $2}' } function getGroupNameByID { cat groups.txt | grep $1 | awk -F"|" '{print $2}' | sed -e 's/ / /g;' } # usage: ListJoinedGroupByID [uid] function ListJoinedGroupByID { local users=$(getUsersListFromList) for user in $users do [[ -z $1 || $1 == $user ]] && { echo "User: $(getUsernameByID $user) ($user)" echo "-------------------------------------------------------------------------------" local this_joined=$(findJoinedGroupByID $user) for this_group in $this_joined do echo "$(getGroupNameByID $this_group) ($this_group) as $(getUsernameInGroupByID $this_group $user)" done echo "-------------------------------------------------------------------------------" echo } done } function getUsernameByID { cat group-*.txt | grep $1 | tail -n1 | awk -F "|" '{print $3}' | sed -e 's/ / /g;' } function getUsernameInGroupByID { local name=$(cat group-$1.txt | grep $2 | awk -F "|" '{print $2}') [[ -z $name ]] && name=$(cat group-$1.txt | grep $2 | awk -F "|" '{print $3}') echo $name | sed -e 's/ / /g;' } $*