1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FreePascal FriendStorm bot

Discussion in 'General Programming Chat' started by Redneck, Jul 23, 2008.

  1. Redneck

    Redneck Newbie

    Joined:
    May 24, 2008
    Messages:
    15
    Likes Received:
    2
    Location:
    South
    This is a bot I made a few months back to add friends to some MS accounts. It was a quick job to test an idea that I had. It gets a list of MS users from friendstorm and then makes it look like you added them to your MS account. FS then puts your MS ID on the list for other people to add you. I tested it about 30 mins ago to make sure it still works. I have already gotten 10 friend requests from that small run.

    This is a command line program. You will need
    FreePascal (FPC): http://h**p://www.freepascal.org/
    and cUrl: http://h**p://curl.haxx.se/

    I use Arch Linux, but this code should compile and run on any OS that you can install FPC and cUrl.

    Save the code into a text file called "friendstorm.pas"
    On Linux, in a terminal, type:
    "fpc friendstorm.pas"
    and it will compile.
    I am not sure how it is done on windows or OSX. Google should help you.


    Code:
    {
    FriendStorm Bot
    Made by: Redneck
    Posted to: BlackHatWorld.com
    }
    program friendstorm;
    
    {$mode objfpc}{$H+}
    
    uses
      {$IFDEF UNIX}{$IFDEF UseCThreads}
      cthreads,
      {$ENDIF}{$ENDIF}
      Classes, SysUtils, StrUtils, libcurl, unixtype;
      
    const
      appdirname: string = 'friendstorm';
      version: string = '0.0.1';
      crazyassdalnum: string = 'oenhwnjfur';
    
    var
      cookkeefile, ourrefcode: string;
      wrkfoldr, workid, minedk, mythreefrndstr: string;
      collectedfriends: TStringList;
      i, alladded: integer;
      
    procedure WriteOutTmpLine(linetawriteout: string);
    begin
      write(#13'' + linetawriteout + DupeString(' ', 79 - Length(linetawriteout)));
    end;
    
    function DoWrite(Ptr : Pointer; Size : size_t; nmemb: size_t; Data : Pointer) : size_t;cdecl;
    begin
      Result:=TStream(Data).Write(Ptr^,Size*nmemb);
    end;
    
    function DoTheCurl(URL, workfldr, cookyfile, repherer, postvarstr, proxytype, proxieport, fillename, soapaction: string; autoreph: boolean; timmeout: integer) : string;
    var
      F : TFileStream;
      hCurl : pCurl;
      tmplist: TStringList;
      i: integer;
      allfile, savedfilename: string;
      K: Text;
      header : Pcurl_slist = Nil;
    begin
      if (fillename = '') then
        savedfilename := workfldr + '/usecurl.html.tmp'
      else
        savedfilename := fillename;
    
      F := TFileStream.Create(savedfilename, fmCreate);
      try
        hCurl:= curl_easy_init;
        if Assigned(hCurl) then
          begin
          header := curl_slist_append(header, 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5');
          header := curl_slist_append(header, 'Accept-Language: en-us,en;q=0.5');
          header := curl_slist_append(header, 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7');
          header := curl_slist_append(header, 'Keep-Alive: 300');
          header := curl_slist_append(header, 'Connection: Close');
          if (soapaction <> '') then
          begin
          header := curl_slist_append(header, 'Content-type: text/xml; charset=utf-8');
          if (soapaction = 'Join') then
          header := curl_slist_append(header, 'SOAPAction: "http://fastgoat.uri/Join"');
          end;
    
          if (repherer <> '') then
            curl_easy_setopt(hCurl, CURLOPT_REFERER, [PChar(repherer)]);
    
    //      curl_easy_setopt(hCurl, CURLOPT_VERBOSE, [True]);
          curl_easy_setopt(hCurl, CURLOPT_URL,[PChar(URL)]);
      if not (proxytype = '0') then
      begin
          curl_easy_setopt(hCurl, CURLOPT_PROXY,[PChar(proxieport)]);
      if (proxytype = '4') then
          curl_easy_setopt(hCurl, CURLOPT_PROXYTYPE, [CURLPROXY_SOCKS4]);
      if (proxytype = '5') then
          curl_easy_setopt(hCurl, CURLOPT_PROXYTYPE, [CURLPROXY_SOCKS5]);
      if (proxytype = '2') then
          curl_easy_setopt(hCurl, CURLOPT_PROXYTYPE,[CURLPROXY_HTTP]);
      end;
          curl_easy_setopt(hCurl, CURLOPT_CONNECTTIMEOUT,[timmeout]);
          curl_easy_setopt(hCurl, CURLOPT_TIMEOUT,[timmeout]);
          curl_easy_setopt(hCurl, CURLOPT_SSL_VERIFYPEER, [FALSE]);
          curl_easy_setopt(hCurl, CURLOPT_NOSIGNAL,[1]);
          curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, [header]);
          if (autoreph = True) then
          curl_easy_setopt(hCurl, CURLOPT_AUTOREFERER,[1]);
          curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION,[1]);
          curl_easy_setopt(hCurl, CURLOPT_ENCODING, [PChar('')]);
          curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION,[@DoWrite]);
          curl_easy_setopt(hCurl, CURLOPT_WRITEDATA,[Pointer(F)]);
          curl_easy_setopt(hCurl, CURLOPT_USERAGENT, [PChar('User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11')]);
          curl_easy_setopt(hCurl, CURLOPT_COOKIEFILE, [PChar(cookyfile)]);
          curl_easy_setopt(hCurl, CURLOPT_COOKIEJAR, [PChar(cookyfile)]);
    
          if not (postvarstr = '') then
          begin
            curl_easy_setopt(hCurl, CURLOPT_POST, [1]);
            curl_easy_setopt(hCurl, CURLOPT_POSTFIELDS,[PChar(postvarstr)]);
          end;
          curl_easy_perform(hCurl);
          curl_easy_cleanup(hCurl);
          end;
      finally
        F.Free;
        if (fillename = '') then
        begin
          tmplist := TStringList.Create;
          allfile := '';
          tmplist.LoadFromFile(savedfilename);
          for i := 0 to tmplist.Count - 1 do
            allfile := allfile + tmplist[i];
    
          Assign (K, savedfilename);
          Erase(K);
          FreeAndNil(tmplist);
          result := allfile;
        end
        else
        begin
          result := fillename;
        end;
      end;
    end;
    
    procedure GetTheRefCode(fromthis : string);
    var
      ourrefcode: string;
    begin
      fromthis := StringReplace(fromthis, '"', '', [rfReplaceAll, rfIgnoreCase]);
      fromthis := StringReplace(fromthis, '''', '', [rfReplaceAll, rfIgnoreCase]);
      fromthis := StringReplace(fromthis, ' /> ', '/>', [rfReplaceAll, rfIgnoreCase]);
      fromthis := StringReplace(fromthis, '/> ', '>', [rfReplaceAll, rfIgnoreCase]);
      ourrefcode := Copy(fromthis, pos('name=movie value=fstorm.swf?refid=', fromthis) + Length('name=movie value=fstorm.swf?refid='), Length(fromthis));
      ourrefcode := Copy(ourrefcode, 1, pos('>', ourrefcode) - 1);
    end;
    
    function HexToInt(HexStr: String): Int64;
    var RetVar : Int64;
        i : byte;
    begin
      HexStr := UpperCase(HexStr);
      if HexStr[length(HexStr)] = 'H' then
         Delete(HexStr,length(HexStr),1);
      RetVar := 0;
    
      for i := 1 to length(HexStr) do begin
          RetVar := RetVar shl 4;
          if HexStr[i] in ['0'..'9'] then
             RetVar := RetVar + (byte(HexStr[i]) - 48)
          else
             if HexStr[i] in ['A'..'F'] then
                RetVar := RetVar + (byte(HexStr[i]) - 55)
             else begin
                Retvar := 0;
                break;
             end;
      end;
    
      Result := RetVar;
    end;
    
    function UrlDecode(const EncodedStr: String): String;
    var
      I: Integer;
    begin
      Result := '';
      if Length(EncodedStr) > 0 then
      begin
        I := 1;
        while I <= Length(EncodedStr) do
        begin
          if EncodedStr[I] = '%' then
            begin
              Result := Result + Chr(HexToInt(EncodedStr[I+1] + EncodedStr[I+2]));
              I := Succ(Succ(I));
            end
          else if EncodedStr[I] = '+' then
            Result := Result + ' '
          else
            Result := Result + EncodedStr[I];
    
          I := Succ(I);
        end;
      end;
    end;
      
    procedure WriteHelp;
    begin
      writeln('Basic usage: ',appdirname,' 12345678');
      writeln('Replace 12345678 with your MySpace id.');
    end;
    
    procedure GetTheSwfRefCode;
    var
      durl, drefer, allstreply: string;
    begin
      durl := 'http://www.friendstorm.net/';
      drefer := 'http://www.friendstorm.net/';
      WriteOutTmpLine('Getting SWF Url...');
      allstreply := DoTheCurl(durl, wrkfoldr, cookkeefile, drefer, '', '0', '', '', '', True, 30);
      GetTheRefCode(allstreply);
    end;
    
    function MakeMeLoginPacket: string;
    var
      taputtogether: string;
    begin
      taputtogether := '<?xml version="1.0" encoding="utf-8"?>' + #13#10;
      taputtogether := taputtogether + '<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="';
      taputtogether := taputtogether + 'http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org';
      taputtogether := taputtogether + '/soap/envelope/"><SOAP-ENV:Body><Join xmlns="http://fastgoat.uri/"><fid>';
      taputtogether := taputtogether + workid;
      taputtogether := taputtogether + '</fid><dal>' + crazyassdalnum + '</dal><ref>';
      taputtogether := taputtogether + UrlDecode(ourrefcode);
      taputtogether := taputtogether + '</ref></Join></SOAP-ENV:Body></SOAP-ENV:Envelope>';
      result := taputtogether;
    
    
    end;
    
    function DoTheLogIn: boolean;
    var
      durl, drefer, dpostvar, allstreply: string;
    begin
      durl := 'http://fstorm.servehttp.com/fstorm/Service.asmx';
      drefer := 'http://www.friendstorm.net/fstorm.swf?refid=' + ourrefcode;
      dpostvar := MakeMeLoginPacket;
      WriteOutTmpLine('logging in through SOAP...');
      allstreply := DoTheCurl(durl, wrkfoldr, cookkeefile, drefer, dpostvar, '0', '', '', 'Join', True, 30);
      if (pos('<JoinResult><ID>' + workid + '</ID>',allstreply) <> 0) then
        result := True
      else
        result := False;
    end;
    
    function MakeMeGetUserPacket: string;
    var
      taputtogether: string;
    begin
      taputtogether := '<?xml version="1.0" encoding="utf-8"?>' + #13#10;
      taputtogether := taputtogether + '<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="';
      taputtogether := taputtogether + 'http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org';
      taputtogether := taputtogether + '/soap/envelope/"><SOAP-ENV:Body><GetFriends xmlns="http://fastgoat.uri/"><id>';
      taputtogether := taputtogether + workid;
      taputtogether := taputtogether + '</id></GetFriends></SOAP-ENV:Body></SOAP-ENV:Envelope>';
      result := taputtogether;
    end;
    
    procedure Split(const Delimiter: Char; Input: string; const Strings: TStrings);
    begin
      Assert(Assigned(Strings)) ;
      Strings.Clear;
      Strings.Delimiter := Delimiter;
      Strings.DelimitedText := Input;
    end;
    
    procedure CleanTheUsers(fromthis : string);
    var
    A : TStringList;
    ii : integer;
    begin
    collectedfriends.Clear;
    fromthis := StringReplace(fromthis, '"', '', [rfReplaceAll, rfIgnoreCase]);
    fromthis := StringReplace(fromthis, '''', '', [rfReplaceAll, rfIgnoreCase]);
    fromthis := StringReplace(fromthis, '<Fr>', 'DataPoint;OnlineNowUserID=', [rfReplaceAll, rfIgnoreCase]);
    fromthis := StringReplace(fromthis, '</I><N>', ';', [rfReplaceAll, rfIgnoreCase]);
    
    A := TStringList.Create;
    Split(';', fromthis, A);
      for ii := 0 to A.Count - 1 do
      begin
        if pos('OnlineNowUserID=', A[ii]) <> 0 then
        begin
          A[ii] := StringReplace(A[ii], 'OnlineNowUserID=', '', [rfReplaceAll, rfIgnoreCase]);
          A[ii] := Trim(A[ii]);
            if (pos('<I>', A[ii]) <> 0) and (collectedfriends.IndexOf(A[ii]) = -1) then
            begin
            collectedfriends.Add(StringReplace(A[ii], '<I>', '', [rfReplaceAll, rfIgnoreCase]));
            end;
        end;
      end;
      A.Free;
    end;
    
    procedure GetTheDynCode(fromthis : string);
    begin
    minedk := Copy(fromthis, pos('<DK>', fromthis) + Length('<DK>'), Length(fromthis));
    minedk := Copy(minedk, 1, pos('</DK>', minedk) - 1);
    end;
    
    procedure GetTheUsers;
    var
      durl, drefer, dpostvar, allstreply: string;
    begin
      durl := 'http://fstorm.servehttp.com/fstorm/Service.asmx';
      drefer := 'http://www.friendstorm.net/fstorm.swf?refid=' + ourrefcode;
      dpostvar := MakeMeGetUserPacket;
      allstreply := DoTheCurl(durl, wrkfoldr, cookkeefile, drefer, dpostvar, '0', '', '', 'GetFriends', True, 30);
      CleanTheUsers(allstreply);
      GetTheDynCode(allstreply);
    end;
    
    function GiveMeThreeFriends: string;
    var
      taputtogether: string;
    begin
      if (collectedfriends.Count < 3) then
      begin
        result := '';
      end
      else
      begin
      taputtogether := taputtogether + '<int>';
      taputtogether := taputtogether + collectedfriends[0];
      taputtogether := taputtogether + '</int><int>';
      taputtogether := taputtogether + collectedfriends[1];
      taputtogether := taputtogether + '</int><int>';
      taputtogether := taputtogether + collectedfriends[2];
      taputtogether := taputtogether + '</int>';
      collectedfriends.Delete(0);
      collectedfriends.Delete(0);
      collectedfriends.Delete(0);
      result := taputtogether;
      end;
    end;
    
    function MakeMyFriendSendPacket: string;
    var
      taputtogether: string;
    begin
      taputtogether := '<?xml version="1.0" encoding="utf-8"?>' + #13#10;
      taputtogether := taputtogether + '<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="';
      taputtogether := taputtogether + 'http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org';
      taputtogether := taputtogether + '/soap/envelope/"><SOAP-ENV:Body><NewAdds xmlns="http://fastgoat.uri/"><myid>';
      taputtogether := taputtogether + workid;
      taputtogether := taputtogether + '</myid><friends>';
      taputtogether := taputtogether + mythreefrndstr;
      taputtogether := taputtogether + '</friends><dyn>';
      taputtogether := taputtogether + minedk;
      taputtogether := taputtogether + '</dyn><dal>' + crazyassdalnum + '</dal></NewAdds></SOAP-ENV:Body></SOAP-ENV:Envelope>';
      result := taputtogether;
    end;
    
    procedure AddTheUsers;
    var
      durl, drefer, dpostvar, allstreply: string;
    begin
      durl := 'http://fstorm.servehttp.com/fstorm/Service.asmx';
      drefer := 'http://www.friendstorm.net/fstorm.swf?refid=' + ourrefcode;
      dpostvar := MakeMyFriendSendPacket;
      allstreply := DoTheCurl(durl, wrkfoldr, cookkeefile, drefer, dpostvar, '0', '', '', 'NewAdds', True, 30);
      alladded := alladded + 3;
    end;
    
    begin
      if (Trim(ParamStr(1))='') then
      begin
        WriteHelp;
        Halt;
      end;
      wrkfoldr := Trim(GetEnvironmentVariable('HOME'));
      wrkfoldr := wrkfoldr + '/.' + appdirname;
      if DirectoryExists(wrkfoldr) = False then CreateDir(wrkfoldr);
      cookkeefile := wrkfoldr + '/cookies.txt';
      if FileExists(cookkeefile) then DeleteFile(cookkeefile);
      workid := Trim(ParamStr(1));
      writeln('Friend Storm Bot v', version);
      writeln('ID you gave: ', workid);
      alladded := 0;
      collectedfriends := TStringList.Create;
      WriteOutTmpLine('Getting SWF Url...');
      GetTheSwfRefCode;
      WriteOutTmpLine('Getting SWF Url...GOT');
      if (DoTheLogIn = False) then
      begin
        writeln(' ');
        writeln('Bad login? Quitting!');
        Halt;
      end;
      WriteOutTmpLine('Friend Storm says you SOAP joined.');
      Sleep(1000);
      WriteOutTmpLine('Getting users...');
      GetTheUsers;
      WriteOutTmpLine('Getting users...' + inttostr(collectedfriends.Count) + ' got.');
      writeln(' ');
      for i := 1 to 16 do
      begin
        mythreefrndstr := GiveMeThreeFriends;
        WriteOutTmpLine('Next up: ' + mythreefrndstr);
        if not (mythreefrndstr = '') then
        begin
          Sleep(4000);
          WriteOutTmpLine('Sending to ' + mythreefrndstr);
          AddTheUsers;
          WriteOutTmpLine('Sent to ' + mythreefrndstr);
          Sleep(1000);
        end;
      end;
      if FileExists(cookkeefile) then DeleteFile(cookkeefile);
      FreeAndNil(collectedfriends);
      writeln(' ');
      writeln('Finished!');
      writeln('All sent: ' + inttostr(alladded));
    end.