#!/bin/sh
# (c) 2008 Mirco Caccia
# http://www.ush.it
# Updated with the new LinkedIn CSRF protection (yes it was CSRFable before) Jul/2008
read COOKIE
echo "Auth cookie is: $COOKIE"
GROUPID=12345
echo "Group is: $GROUPID"
AGENT="Mozilla/5.0 (123) Gecko/123 Iceweasel/123 (Debian-123)"
echo "User-Agent is: $AGENT"
SUBJECT="Invitation+to+connect+on+LinkedIn"
BODY="I%27d+like+to+add+you+to+my+professional+network+on+LinkedIn.%0D%0A%0D%0A-YournameHere"
echo "Sending message: $SUBJECT, $BODY"
curl -kis "http://www.linkedin.com/gmt?groupID=$GROUPID&displayApplicants=" \
-H "Cookie: $COOKIE" \
-A "$AGENT" | \
grep "/profile?viewProfile=&key=.*&authToken=\|
.* | $" | \
sed -e :a -e "s/<\/a><\/td>.* /|/g;//|/g;s/ <\/td>$//g" \
2>/dev/null > new.txt
cat new.txt | while read f; do
ID="`echo $f | cut -d "|" -f1`";
NAME="`echo $f | cut -d "|" -f2`";
MAIL="`echo $f | cut -d "|" -f3`";
CSRF_TOKEN=`curl -vvv -kis "http://www.linkedin.com/invite" \
-H "Cookie: $COOKIE" \
-A "$AGENT" \
2>&1 | grep "/invite" | grep "csrfToken" | sed "s/^.*value=\"//g;s/\".*$//g";`
FNAME="`echo $NAME|cut -d"," -f2`"
LNAME="`echo $NAME|cut -d"," -f1`"
curl -vvv -kis "http://www.linkedin.com/invite" \
-d "csrfToken=$CSRF_TOKEN&firstName=$FNAME&lastName=$LNAME&emailAddress=$MAIL&subject=$SUBJECT&greeting=$BODY&invite=Send&isMessageOptional=false&from=default&inviteeID=&contentTemplateID=std_inv_9" \
-H "Cookie: $COOKIE" \
-A "$AGENT" \
2>&1 | grep "^Location: \|Invitation to \|You have recently";
done
rm new.txt
echo "Now approve the first page of pending join requests."
echo
|