Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Newbie programmer with an idea


  • Please log in to reply
9 replies to this topic

#1 Ubernoober13

Ubernoober13

  • Members
  • 18 posts
  • OFFLINE
  •  
  • Local time:04:45 PM

Posted 11 July 2013 - 10:35 PM

Hello everyone I am a fairly new programmer only learning Java from my AP Computer Science class this year and find it very useless besides the general theroy. I have decided to start learning JavaScript. I am not here to ask what the best tutorials are because I have found some that I like and going to go through all the tutorials. But you don't need my life story so lets stay on topic.

 

My idea is this. I play this web based real time strategy game called Travian. My buddies and I like to make time attacks that land at the same time to cause panic for the enemy. The problem is, we launch from different location and have different launch times. Sometimes some people can't make their time. I want to design a program that does the following as an addon for firefox.

 

  • Asks for the land time they want
  • Inputs the troops for the attacks
  • Looks at travel time
  • Find server clock and keep it up to date(located on the top of every page in the game)
  • Compares land time to servers clock
  • Launches at appropriate time to land
  • Able to send multiple waves to land in the same second

Here is an example on how I would be sending the waves.

 

 

My main issue is how do I find the server clock and how should I compare it?

Would a simple if statement like this work?

if (server clock == land time){
send waves
}

Is there a way to do the multiple waves? Somehow switching tabs and launching attacks(Just pressing the launch button) I know a human will take a few second but I think a computer can do that in a milisecond.

 

 

Any help would be amazing please no hate.


Edited by Ubernoober13, 11 July 2013 - 10:40 PM.


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:45 PM

Posted 12 July 2013 - 09:55 AM

I know of no way to retrieve server time from a server (using javascript) I do not own without the server having an api, or without having physical access to the server. On a properly hardened system, you will not be able to get any information about hte server other than some very general information abouut the server software, maybe the OS, and some version info. Put another way, I ant you to know as little about my server as possible, because even revealing the time zone is another piece of info that I do not want a potential attacker to have.

 

In order to retrieve system time using Javascript, I would need a file on the server ( the system being checked) that the javascript on my machine could talk to in order to retrieve the system time. There are some instances in which VBScript can be used, but again, that requires physical access to the server.

 

The only other ways that I can think of use tools designed for penetration testing, and various scripts designed to profile remote servers. I can't think of any that are Javascript based, and at any rate, if you are using these tools against a remote server, they will likely recognize it and ban your account. Again, this all depends on how the server has been configured.

 

In summary, I can't think of any way that would be reliable (or legal in many cases) using Javascript.

 

However, since you mention that the web page contains the server time, then you can use a technique called screen scraping, and that is easy enough to do. I looked at the code for the page, and the time is conatined in these two elements:

<span id="tp1">15:26:27</span>


<span class="timezone">(GMT +01:00)</span>

Using Javascript, I can make an asynchronous request to the server to get all of the page contents. I can use plain vanilla Javascript, but dealing with cross-brower issues is no fun, so it is much easier (and cleaner) to use something like JQuery or YUI to do the heavy work for you. For instance, using JQuery I can read the entire contents of a web page into a single variable that represents the entire web page.

[code=auto:0]

 

$.get("http://www.travian.com", function(response) { alert(response) });

[/code]

Once you have the contents of the page, then you can process the object to find the values that you want. Again, depending on how the system is configured, this might not work either. Sites like Google and Amazon prevent this from happening in order to prevent fraudsters from replicating their content and representing themselves as Google and Amazon.


Edited by groovicus, 13 July 2013 - 08:10 PM.


#3 Ubernoober13

Ubernoober13
  • Topic Starter

  • Members
  • 18 posts
  • OFFLINE
  •  
  • Local time:04:45 PM

Posted 13 July 2013 - 07:28 PM

So there is no easy way to find different buttons like the launch button? Is there a language that would allow me to find those buttons and click them?



#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:45 PM

Posted 13 July 2013 - 08:12 PM

You can try and use screen scraping to find the elements that you want, and manipulate them in any way that you want.



#5 Ubernoober13

Ubernoober13
  • Topic Starter

  • Members
  • 18 posts
  • OFFLINE
  •  
  • Local time:04:45 PM

Posted 13 July 2013 - 08:18 PM

What is screen scraping? Just did a quick search and it seems like an application that finds things on websites like buttons. Is that correct?

Couldn't right clicking on firefox and doing inspect elements work as well as long as I figure out where the button is? If not is there a free way to do screen scraping? Everything seems to cost, if not what is the best program to use?


Edited by Ubernoober13, 13 July 2013 - 08:28 PM.


#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:45 PM

Posted 13 July 2013 - 10:17 PM

Screen scraping is a technique to load a representation of a web page into a data structure that can be accessed programatically, as long as the structure is predictable. You need to write the code to do this.



#7 Ubernoober13

Ubernoober13
  • Topic Starter

  • Members
  • 18 posts
  • OFFLINE
  •  
  • Local time:04:45 PM

Posted 13 July 2013 - 10:31 PM

Screen scraping is a technique to load a representation of a web page into a data structure that can be accessed programatically, as long as the structure is predictable. You need to write the code to do this.


Do you know of any tutorials on how to do this? I know we aren't suppose to ask for those here but with Google searching all i get is things to buy. I also read it's something to do with identity theft. Is screen scraping illegal?

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:45 PM

Posted 13 July 2013 - 11:04 PM

Oh man. This is going to cut into my gaming time, but I will try to help.

 

Screen scraping is not illegal. Once the code is in your web browser, you are free to examine it any manner you choose. Hit 'f12' in IE or Firefox, and a  debugger will open, giving you access to all of the underlying code of any web page. With the correct application, you can examine any application on your system. That is not to say that you will understand any of what you may see, but to emphasize the idea that all code on your system is accessible in one way or another.

 

Understanding how to manipulate the DOM goes hand in hand with understanding how to use Javascript. Without that, there is no foundation for understanding how to do screen scraping. I will see if I can find some example that I can maybe adopt.


Edited by groovicus, 14 July 2013 - 08:05 AM.
spelling


#9 Ubernoober13

Ubernoober13
  • Topic Starter

  • Members
  • 18 posts
  • OFFLINE
  •  
  • Local time:04:45 PM

Posted 13 July 2013 - 11:50 PM

With the correct application, you can examine any application on your system.

 

I really take your time, I really do. I am just trying to learn. What is the correct program? Do I have to create it? Is it different for each website, depending on how the website is set up? Sorry for all the questions.



#10 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:45 PM

Posted 14 July 2013 - 07:02 PM

Look at the code in the accepted answer on this page: http://stackoverflow.com/questions/5667880/simple-screen-scraping-using-jquery

 

 


 

Use $.ajax to load the other page into a variable, then create a temporary element and use .html() to set the contents to the value returned. Loop through the element's children of nodeType 1 and keep their first children's nodeValues. If the external page is not on your web server you will need to proxy the file with your own web server.

Something like this:

$.ajax({
     url: "/thePageToScrape.html",
     dataType: 'text',
     success: function(data) {
          var elements = $("<div>").html(data)[0].getElementsByTagName("ul")[0].getElementsByTagName("li");
          for(var i = 0; i < elements.length; i++) {
               var theText = elements[i].firstChild.nodeValue;
               // Do something here
          }
     }
});

If you do not undertand what this code is doing, then you are not ready to tackle this. If you do unterstand the code, you wil see that it is easy to find a value on a page. That's about all of the help I can give. I can't teach you javascript, so there is going to be a certain amount of effort required by you to learn.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users