cacti
+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Create Your First BOT

  1. #1
    Join Date
    Jan 2005
    Posts
    623

    Create Your First BOT

    Create Your First BOT

    This will be a very, very basic tutorial on what a bot is and how to create one. First you need to understand that a "BOT" is only a series of programming commands/functions that do "SOMETHING".

    In this example my bot will: GRAB ALL USERNAMES FROM ALL-NETTOOLS.COM

    First we need to find out how all-nettools.com displays usernames so first we need to click on "[url=http://www.all-nettools.com/forum/memberlist.php]Member List[/url]".

    Notice the URL structure of each user profile: [url]http://www.all-nettools.com/forum/member.php?u=657*[/url]
    With a little digging you will find that the first user (OTTO - administrator) is
    [url]http://www.all-nettools.com/forum/member.php?u=*[/url]

    We can now get started writing our bot. You need to make a step by step list of what you want the bot to do.


    *. Check to see if URL exists
    2. Grab HTML from URL
    *. Find username starting point in html
    4. Find username ending point in html
    5. Grab next URL


    PHP CODE
    Code:
    function bot_allnettools($user){
    	// CHECK TO SEE IF URL EXISTS
    	if($current_webpage=file_get_contents("http://www.all-nettools.com/forum/member.php?u=" . $user)){
    		
    		$user_identifier_beginning="<div class=\"bigusername\">";
    		$user_identifier_end="<img";
    		
    		// CHECKS FOR MATCHING PATTERN WITH BEGINNING AND ENDING IDENTIFIERS (NOTICE THE WILDCARD IN THE MIDDLE)
    		if (preg_match('/' . $user_identifier_beginning . '(.*?)' . $user_identifier_end . '/',$current_webpage,$match)) {
    			$match[0]=str_replace($user_identifier_beginning,"",$match[0]);
    			$match[0]=str_replace($user_identifier_end,"",$match[0]);
    			return($match[0]);
    		}
    	}
    	return(0);
    }
    I am not posting my live example because it uses a lot of the bandwidth allocated to all-nettools.com. This was only an example so please do not use this information to create bots on all-nettools.com or you will be permanently banned and reported to your ISP.

    ~SyntaX
    Last edited by SyntaXmasteR; 08-21-2007 at 07:34 PM.
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  2. #2
    Join Date
    Sep 2006
    Posts
    1,651
    I think something like this is possible using cURL with less code, but I'd have to whip up something to see if it can be smaller than that, and not all web hosts (at least not all free ones) support cURL.

    But nevertheless, that's a nice tut

  3. #3
    Join Date
    Jan 2005
    Posts
    623
    Hey Moonbat, let me know if you know of any easier ways of doing this. I was trying to find a php command for find and replace (BUT ONLY ONCE). I could not find this anywhere. If you know of a command please let me know. The reason I need this:

    HTML
    Code:
    This is my code I will place a link here <a href="BLAH.com">This is the first link</a>I do not need this link.  I would like to get to the starting point of this link but I cant if they contain the same code <a href="BLAH.com">This is the first link</a>.
    My idea behind finding the starting point of the second <a href tag is to do a find and replace on the first one to change it to (WHATEVER). Then do a strpos() function on the html that will grab the second starting point. How do you do a find and replace, only once. Does this function exist?

    Thanks to whomever can answer this, it will greatly help out!

    ~SyntaX
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  4. #4
    Join Date
    Mar 2007
    Posts
    24
    nice.. this might come in handy for one of my sites sometimes =)
    thanks for sharing bro

  5. #5
    Join Date
    Jan 2005
    Posts
    623
    I'm horrible at regular expressions but I updated the code with a cleaner version than the one I posted earlier using.
    Last edited by SyntaXmasteR; 08-21-2007 at 07:37 PM.
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  6. #6
    Join Date
    Sep 2006
    Posts
    1,651
    Oh yeah, that looks much better

  7. #7
    Join Date
    Sep 2005
    Posts
    2,053
    Steps * and 4 would be much easier to accomplish with Javascript using the HTML DOM, but you need the server-side scripting for such actions as writing the username list to file, and of course when putting these scripts on an external server (not on all-nettools.com domain), you can't use any AJAX skills to retrieve pages and traverse the DOM.

    Maybe you could use this to simplify the parsing:

    [url]http://php.net/domxml[/url]

    I doubt this site's code is valid enough to be treated as XML though.

    By the way, you should revert to writing opening/closing braces the way you used to (as said in other thread):

    Code:
    if($lol)
    {
    $lulz = *;
    }
    else
    {
    $lulz = 0;
    }
    Support the style you know is right!
    Last edited by Ezekiel; 08-22-2007 at 11:50 AM.

  8. #8
    Join Date
    Jan 2005
    Posts
    623
    Mike

    Throw your best XML, DOM, AJAX, & JAVASCRIPT tutorials at me. I need a strong starting point, that gives great examples for each new application that it teaches.

    I've overloaded myself on PHP, MYSQL, & serious data validation. Data validation has taken a while. I'm ready to move on to new Web 2.0 stuff, but I like to learn the absolute correct way & not the "hack the code to make it work" way.

    What order should I learn them in? Javascript, XML, DOM, AJAX ?
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  9. #9
    Join Date
    Sep 2005
    Posts
    2,053
    I'm up to my neck in priorities right now, so unfortunately I can't provide any tuts on the subject.

    I'm no expert; w*schools.com taught me most of what I know, and the rest was trial, error and improvement. Probably not the correct way, and I'd say I'm a Javascript noob.

    The best thing I've made in Javascript was the real-time forum topics update box for my site, but I couldn't be bothered to apply the Web 2.0 crap to my whole site so I reverted to pulling it from the database on each request. I think I deleted the whole code for that.

    If you look on my site, the containers can be minimised and maximised. Pointless, but here's the code:

    Code:
    function minimizeContainer(containerTopId, containerHeaderId, containerContentId, containerFooterId)
    {
    	if(document.getElementById(containerTopId) && document.getElementById(containerContentId) && document.getElementById(containerHeaderId) && document.getElementById(containerFooterId))
    	{
    		document.getElementById(containerContentId).style.display = "none";
    		document.getElementById(containerFooterId).style.display = "none";
    		document.getElementById(containerHeaderId).style.marginBottom = "*em";
    		return *;
    	}
    	else
    	{
    		return 0;	
    	}
    }
    
    function maximizeContainer(containerTopId, containerHeaderId, containerContentId, containerFooterId)
    {
    	if(document.getElementById(containerTopId) && document.getElementById(containerContentId) && document.getElementById(containerHeaderId) && document.getElementById(containerFooterId))
    	{
    		document.getElementById(containerContentId).style.display = "block";
    		document.getElementById(containerFooterId).style.display = "block";
    		document.getElementById(containerHeaderId).style.marginBottom = "0";
    		return *;
    	}
    	else
    	{
    		return 0;	
    	}
    }
    
    function closeContainer(containerTopId, containerHeaderId, containerContentId, containerFooterId)
    {
    	if(document.getElementById(containerTopId) && document.getElementById(containerContentId) && document.getElementById(containerHeaderId) && document.getElementById(containerFooterId))
    	{
    		document.getElementById(containerTopId).style.display = "none";
    		document.getElementById(containerHeaderId).style.display = "none";
    		document.getElementById(containerContentId).style.display = "none";
    		document.getElementById(containerFooterId).style.display = "none";
    		return *;
    	}
    	else
    	{
    		return 0;	
    	}
    }
    Creating the Digg links, etc.:

    Code:
    function createNavigationBarLink(listItemClass, linkHref, linkClass, imageSource, imageWidth, imageHeight, imageAlt)
    {
    
    	if(listItemClass && linkHref && linkClass && imageSource && imageWidth && imageHeight && imageAlt)
    	{
    		var nameSpace = "http://www.w*.org/****/xhtml";
    		var listItem = document.createElementNS(nameSpace, "li");
    		listItem.setAttribute("class", listItemClass);
    		document.getElementById("navigation_bar").getElementsByTagName("ul")[0].appendChild(listItem);
    		var link = document.createElementNS(nameSpace, "a");
    		link.setAttribute("href", linkHref);
    		link.setAttribute("class", linkClass);
    
    		if(!listItem.appendChild(link))
    		{
    			return 0;
    		}
    
    		var image = document.createElementNS(nameSpace, "img");
    		image.setAttribute("src", imageSource);
    		image.setAttribute("width", imageWidth);
    		image.setAttribute("height", imageHeight);
    		image.setAttribute("alt", imageAlt);
    
    		if(!link.appendChild(image))
    		{
    			return 0;
    		}
    
    		return *;
    		}
    		else
    		{
    			return 0;
    		}
    }
    I mostly learn as I go along.

    For this, I was implying that you use an XMLHTTP request to load the member page's DOM tree, then find the part you want and pull data from that node. All these sorts of dynamic browser requests are limited to the current domain, so syntax******.info couldn't get its users' browsers to pull the page from all-nettools.com. If it was on all-nettools, the info could be sorted with JS in the user's browser.

    I can't type coherently again, so I'm probably making mistakes.

    What order should I learn them in? Javascript, XML, DOM, AJAX ?
    First make sure you know HTML well enough, then learn about XML documents and XHTML so you can make your sites all valid XHTML or even XML. Then, you can use Javascript to work with the DOM, which is basically the structure of a web page. Each element (such as <div></div>) is a node, and you can move up and down the tree. You can manipulate data in nodes; their attributes, etc.

    AJAX is just a web 2.0 term to describe the way that pages can be dynamic. Javascript can be used to request XML from a server without a whole page re*****, then the XML can be parsed for whatever reason.
    Last edited by Ezekiel; 08-22-2007 at 07:04 PM.

  10. #10
    Join Date
    Aug 2007
    Posts
    2
    nice tutorial =)

  11. #11
    Join Date
    Aug 2007
    Posts
    6

    Nice

    i think i may have found what im looking for as i have posted here asking where and now to learn hacking i think this will be more interesting to learn all that code just look far to intriguing just to leave alone and not fined out what it does exactly and why

    ps. SyntaX****** listened to your advice when i singed up to your web page and now trying to fined out about HTML as a language

    only thing is when on your site none of the tabs work and only get one page telling me about your site would like help please getting to more content
    really sorry about the spelling and what not i have (dyslexia) GIYF it's my friend best spell checker i know it just means i have to work longer and harder

  12. #12
    Join Date
    Jan 2005
    Posts
    623
    I'm building my site component by component. Its very complicated (at least to me) because I am writing the code using a flag system I created. It has three security levels.

    Level *: User based flags
    Level 2: IP based flags
    Level *: Sitewide flags

    A flag is thrown when a user inputs bad data or executes unnatural POST or GET requests. The user will be blocked after (X) ammounts of flags in (X) ammount of time. The IP will be blocked after (X) ammounts of flags in (X) ammount of time. Finally the site will put itself into a safemode after (X) ammounts of flags in (X) ammount of time.

    Keep checking back soon, things will fill out.

    ~SyntaX
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  13. #13
    Join Date
    Aug 2007
    Posts
    7
    lol descent tut. But u should really explain the rest lol. theres other methods of doing this n there are alot of bots to be made. for example a myspace bot made just for myspace. lol still a nice tut. im not trying to degrade anyone but u really should post up the tut on other bots not just the basics. unless theres a topic i missed.
    [IMG]http://i*6.tinypic.com/67*0w*6.gif[/IMG]

  14. #14
    Join Date
    Sep 2005
    Posts
    2,053
    Quote Originally Posted by HeX CoDeR View Post
    for example a myspace bot made just for myspace.
    Good luck writing a program to parse Myspace's code as valid HTML.

  15. #15
    Join Date
    Jan 2005
    Posts
    623
    unless theres a topic i missed.
    Try reading the title of this topic. Creating your first bot. Why would I include *00,000 different bot types for every possible scenario for a simple bot explanation.
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

+ Reply to Thread

Similar Threads

  1. how would i create a http server
    By dipman44 in forum Internet Privacy
    Replies: 6
    Last Post: 06-25-2015, 02:13 AM
  2. Create Your Own Prank
    By SyntaXmasteR in forum Programming
    Replies: 17
    Last Post: 11-02-2009, 06:32 AM
  3. How create polls?
    By idnedhelper in forum General discussion
    Replies: 2
    Last Post: 11-13-2007, 10:58 AM
  4. can Anyone Create a Php mailer?
    By ghost22 in forum Programming
    Replies: 0
    Last Post: 02-12-2007, 06:05 PM
  5. create your own whatismyip
    By ~~smart~fool~~ in forum Programming
    Replies: 1
    Last Post: 12-03-2006, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts