hi every one How can send data to a page (communicate directly with a web server)whithout using any browsers(opera,firefox,...). I just heared something about telnet and i don't know anymore about it. Example: * * $ telnet example.org 80 Trying 192.0.34.166... Connected to example.org (192.0.34.166). Escape character is '^]'. GET / HTTP/1.1 Host: example.org HTTP/1.1 200 OK Date: Sat, 21 May 2005 12:34:56 GMT Server: Apache/1.3.31 (Unix) Accept-Ranges: bytes Content-Length: 410 Connection: close Content-Type: text/html <html> <head> <title>Example Web Page</title> </head> <body> <p>You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.</p> <p>These domain names are reserved for use in documentation and are not available for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RFC 2606</a>, Section 3.</p> </body> </html> Connection closed by foreign host. $ HTML: * * This request can be made with the following PHP code: * * <?php $http_response = ''; $fp = fsockopen('example.org', 80); fputs($fp, "GET / HTTP/1.1\r\n"); fputs($fp, "Host: example.org\r\n\r\n"); while (!feof($fp)) { $http_response .= fgets($fp, 128); } fclose($fp); echo nl2br(htmlentities($http_response, ENT_QUOTES, 'UTF-8')); ?> PHP: * * I really wondered if someone explain examples to me. thank you in advance
mehdiali what you ask is typically what hackers do or try to do or want to learn to do ... hence i suggest we LEAVE the answer OPEN and unanswered by experts! NO honest person ever would want to do so and we definitely want to avoid to become hackers' helpers / info source here in DP forum !!! the examples you show are typical hacker abuse of sites
hans 1.i am not a hacker 2.yes, it is clear that this script is used by somebody that most of them maybe are hacker. but you tell me, if i want to pervent them , i don't need to know how they do or what approach they use? 3.this $ telnet example.org 80 Trying 192.0.34.166... Connected to example.org (192.0.34.166). ..... ....... is a page of "OReilly.Essential.PHP.Security.Oct.2005" book.you can get it from flazx.om 4. i understand you and you tell truth(it is a REALLY bad idea to give to such typical hacker questions any advice) but i'm not a hakcer. 5.have a good day.
There are actually plenty of legitimate reasons to use something other than a browser to connect to a webserver and I have even used telnet in the past. Mostly I use "curl" or, if that doesn't suit my needs "wget". Just type "curl www.domain.com" on the command line and it will retrieve the webpage at that address. If you want to see the HTTP headers, try "curl --include www.domain.com" As for telnet, you actually have everything you need in your first post. [B]telnet example.org 80[/B] Trying 192.0.34.166... Connected to example.org (192.0.34.166). Escape character is '^]'. [B]GET / HTTP/1.1 Host: example.org[/B] HTTP/1.1 200 OK Date: Sat, 21 May 2005 12:34:56 GMT Server: Apache/1.3.31 (Unix) Accept-Ranges: bytes Content-Length: 410 ... ... Code (markup): The bits in bold are the bits you have to type. You will have to hit return twice after the "host: example.org" part but I couldn't figure out how to make a newline look bold You can request different pages on the website by using GET /otherpage.html HTTP/1.1. The same goes for curl: curl www.domain.com/otherpage.html It really depends on what you're trying to achieve. If you want this to happen in a script rather than by you typing on the command line then the PHP method looks like the right one to use. You can script in other languages but unless you're trying to learn a new language it's best to stick to what you know. One of the most common reasons I use curl with my own webservers is to time how long it takes to return just the html of the page. If I time it with a browser I end up having to wait for all of the javascript and css to download before I can even view the page. With the command line, I just type "time curl mydomain.com 2> /dev/null" and it prints out how long it took to retrieve the page.