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

I'm moving away from browser bots, I need suggestions.

Discussion in 'General Programming Chat' started by xpro, Jun 15, 2010.

?

Which language for writing bots in little time?

  1. C#

    0 vote(s)
    0.0%
  2. Java

    0 vote(s)
    0.0%
  3. PHP

    0 vote(s)
    0.0%
  1. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    Hello

    I used to write all my bots witch worked with the browser, but they are unreliable and slow. I've been trying to move away from it, but I'm having a hard time finding something that I can use to write my bots in little time. My main concern is the time it takes to write bots and I want the code to be pretty small. Which language would be the best for that?


    Best Regards
     
  2. satyawrat

    satyawrat Jr. VIP Jr. VIP

    Joined:
    Jul 8, 2009
    Messages:
    933
    Likes Received:
    1,186
    Occupation:
    Hustler
    Location:
    Gurgaon
    Home Page:
    I would say python
    why?

    java code

    class fknjava
    public static void main
    {
    System.out.println("Hello Fucker!@")
    }

    In python
    print ("Hello Fucker")
     
  3. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    I made a yahoo mail auto responder using browser bots, would the same thing be possible with out using a browser? Would it take a lot more coding?
     
  4. Derek Foreal

    Derek Foreal Junior Member

    Joined:
    Apr 10, 2010
    Messages:
    190
    Likes Received:
    767
    Gender:
    Male
    Location:
    East Coast USA
    I guess it depends on what you want to automate exactly, I would definitely say Python also, as it's relatively easy to learn, and you don't have to write tons and tons of code.
     
  5. smack

    smack Junior Member

    Joined:
    Feb 1, 2010
    Messages:
    182
    Likes Received:
    78
    Occupation:
    Software Engineer/Evil Genius
    Location:
    inside .NET
    i recommend either vb.net of c#

    .net is a well documented and supported rapid development platform mounted on solid oop and a robust framework.

    search for some of my other posts about this subject. i have put out a lot of information on .net
     
    • Thanks Thanks x 1
  6. Rambaldi

    Rambaldi Registered Member

    Joined:
    Nov 30, 2009
    Messages:
    81
    Likes Received:
    11
    Occupation:
    Programmer
    Location:
    Sweden
    In .NET, take a look at WebClient class.

    In PHP, use CURL.
     
  7. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    Thanks for all the suggestions guys. I've chosen C# to write my bots in. I will start writing a bot tonight which requires logging in and sending PMs.
     
  8. w84it

    w84it Regular Member

    Joined:
    Jun 18, 2009
    Messages:
    442
    Likes Received:
    752
    may i suggest this HTTP library for use with C# (supports most languages)
    Code:
    http://www.chilkatsoft.com/HttpDotNet.asp
    you can easily find the cracked version

    Example Code:
    Code:
    http://www.example-code.com/csharp/http.asp
    GL :)
     
  9. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    ok guys, so I've started writing the bot for mocospace and I'm using httpfox to see the requests/responses.

    I checked the post string and it looks like this

    "action=login&login_name=Anastasiahiggins&password=a12345678&user_key=-1763759965"

    what caught my eye was "user_key=-1763759965" and than I checked the login page and found it was a randomly generated number which got passed in the POST string. What is the best way to extract stuff from source in C#? I would need to extract that and send it with the POST string.

    Best Regards!
     
  10. WickednDivine

    WickednDivine Executive VIP Premium Member

    Joined:
    Jul 29, 2008
    Messages:
    468
    Likes Received:
    344
    Perl or Ruby + WWW::Mechanize (or Mozilla::Mechanize if you need javascript handling).
     
  11. nahid5692001

    nahid5692001 Regular Member

    Joined:
    Aug 30, 2009
    Messages:
    357
    Likes Received:
    117
    I would use PHP for extracting POSTs. you can extra items from a url really easily with PHP
     
  12. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    I'm trying yo parse the html generated from the login page. What is the best way to do it using c#?
     
  13. w84it

    w84it Regular Member

    Joined:
    Jun 18, 2009
    Messages:
    442
    Likes Received:
    752
    Regex :) tricky stuff to get used to
     
    • Thanks Thanks x 1
  14. smack

    smack Junior Member

    Joined:
    Feb 1, 2010
    Messages:
    182
    Likes Received:
    78
    Occupation:
    Software Engineer/Evil Genius
    Location:
    inside .NET

    regex is a damn fine solution as w84it said. i'm not that strong with regex, so i usually use the string parsing in the framework. it's more brittle but it's a comfortable technique for me. if you're good with regex though i encourage you to go that route.

    i don't have a c# version of this function handy, but this should give you a basic idea.

    Code:
       Public Function Parse(ByVal origionalData As String, ByVal prefix As String, ByVal suffix As String) As String
            Dim returnData As String = ""
            Dim preLoc As Integer = InStr(origionalData, prefix)
    
            If preLoc > 0 Then
                Dim tempBuffer As String = Mid(origionalData, preLoc + prefix.Length)
                Dim suffLoc As Integer = InStr(tempBuffer, suffix)
                If suffLoc > 0 Then
                    returnData = Mid(tempBuffer, 1, suffLoc - 1)
                End If
            End If
    
            Return returnData
        End Function
    also, take a look at the string class on msdn. that spells out all the methods you can use for string manipulation.

    Code:
    http://msdn.microsoft.com/en-us/library/system.string.aspx
     
    • Thanks Thanks x 1
  15. madblacker

    madblacker Regular Member

    Joined:
    Nov 2, 2009
    Messages:
    268
    Likes Received:
    19
    The language is irrelevant, just use what you are most comfortable with... I started off with VBscript but quickly got tired of it being hard to find documentation and now I use PHP... I still haven't grasped building bots outside of the browser (i still use imacros) because I don't know enough about packet sniffing / re-assembly, etc .. but I am sure it doesn't matter since any language has a method for doing web calls (like curl in PHP).. the main thing is to be comfortable with using a database with your programming language (like mysql) since you need to use this effectively to build efficient bots / apps
     
  16. madblacker

    madblacker Regular Member

    Joined:
    Nov 2, 2009
    Messages:
    268
    Likes Received:
    19
    As far as extracting URLs, look into Grep programs (they have some for windows and also in linux), you can program using Grep, such as in PHP, but its time consuming to get started with it if you aren't used to it, so right now I just do a manual grep on a huge file that I compile from my php script... but basically you just want to get each url line separated and then put it into a mysql database... then in mysql its really use to use the "like" function (google it) to retrieve strings that from a database column that match something so like if you're just doing email confirmations or something you can just use this to match a specific username,etc
     
  17. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    I found this program which helps to create regexes in a faster and more reliable way. here you go guys

    HTML:
    http://www.ultrapico.com/Expresso.htm
     
  18. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    I wrote some code, but I keep getting runtime errors when trying to post data. Here is what I have so far.


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.IO;
    using System.Text.RegularExpressions;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string key = "";
                ASCIIEncoding encoding = new ASCIIEncoding();
                CookieContainer cookieContainer = new CookieContainer();
    
    
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.mocospace.com/html/login.jsp");
                request.CookieContainer = cookieContainer;
                request.ContentType = "application/x-www-form-urlencoded";
                request.UserAgent = "Mozilla/4.0(PC) (compatible; MSIE 8.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
    
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
                StreamReader stream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.ASCII);
                String result = stream.ReadToEnd();
    
                response.Close();
    
                // Here we call Regex.Match.
                Match match = Regex.Match(result, "<input type=\"hidden\" name=\"user_key\" value=\"(.*)\"/>", RegexOptions.IgnoreCase);
    
                // Here we check the Match instance.
                if (match.Success)
                {
                    key = match.Groups[1].Value;
                    Console.WriteLine(key);
                }
    
                String loginData = "action=login&login_name=Anastasiahiggins&password=a12345678&user_key=" + key;
                byte[] data = encoding.GetBytes(loginData);
                Console.WriteLine(loginData);
    
                try
                {
                    request.Method = "POST";
                    request.ContentType = "application/x-www-form-urlencoded";
                    request.ContentLength = data.Length;
    
                    Stream newStream = request.GetRequestStream();
                    newStream.Write(data, 0, data.Length);
                    newStream.Close();
                }
                catch(Exception e){
                    Console.WriteLine(e);
                }
                
    
    
                TextWriter tw = new StreamWriter("result.html");
                tw.WriteLine(result);
                tw.Close();
    
                response.Close();
                stream.Close();
            }
        }
    }
    
    

    It works up to the point I extract the user_key, but I tried to make the POST work but I kept getting runtime errors. Can anyone see what I'm doing wrong?


    Best Regards!
     
  19. Rambaldi

    Rambaldi Registered Member

    Joined:
    Nov 30, 2009
    Messages:
    81
    Likes Received:
    11
    Occupation:
    Programmer
    Location:
    Sweden
    Read what I wrote.. use WebClient class..
     
  20. *Candi*

    *Candi* Regular Member

    Joined:
    Jun 11, 2010
    Messages:
    311
    Likes Received:
    40
    Occupation:
    SEO Consultant :)
    Location:
    First Page Of Google
    I think you can use python for its easy and short coding:loser: