mIRC Homepage
Posted By: eawedat Socket's website connection - 18/11/11 03:44 PM
Code:
on *:sockopen:x:{ 
  sockwrite -n $sockname GET / HTTP/1.1 
  sockwrite -n $sockname Host: eawedat.zxq.net $+ $crlf
  ;I DO NOT KNOW IF CODE BELOW IS NECESSARY
  ;sockwrite -n $sockname Connection: Keep-Alive
}

on *:sockread:x:{
  if ($sockerr) {
    echo -a Error
    halt
  }
  else {
    sockread %temptext
    echo -a %temptext
  }
}


Code:
Usage:- /sockopen x eawedat.zxq.net 80


but I do not get desired results!
I get this:-

Code:
HTTP/1.1 400 Bad Request
Date: Fri, 18 Nov 2011 15:40:52 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>


thanks a lot.
Posted By: Riamus2 Re: Socket's website connection - 18/11/11 05:22 PM
Code:
on *:sockopen:x:{ 
  sockwrite -n $sockname GET / HTTP/1.1
  sockwrite -n $sockname Host: eawedat.zxq.net
  sockwrite -n $sockname
}
Posted By: eawedat Re: Socket's website connection - 18/11/11 05:40 PM
yeah thanks a lot it is working
but Riamus2 ,

Code:
sockwrite -n $sockname Host: eawedat.zxq.net $+ $crlf



Code:
sockwrite -n $sockname Host: eawedat.zxq.net
sockwrite -n $sockname


aren't the same?

because: $+ $crlf is also sending a newline

thanks.
Posted By: Riamus2 Re: Socket's website connection - 18/11/11 08:48 PM
If you sent 2 $crlf's, it would probably work on yours. But it's considered better to use a single -n at the end instead of manually doing $crlf.
Posted By: eawedat Re: Socket's website connection - 18/11/11 09:12 PM
I see thanks a lot:))
Posted By: eawedat Re: Socket's website connection - 18/11/11 10:00 PM
Riamus2
by the way , when I run :
/sockopen x eawedat.zxq.net 80

it complains about 31 times that :
* /echo: insufficient parameters (line 16, remote.ini)

line 16 :
echo -a %temptext

why's that? & how can I avoid those messages?

thanks.
Posted By: Riamus2 Re: Socket's website connection - 18/11/11 11:49 PM
It's because your page has a lot of blank lines in the code. Just put a check to only echo if != $null.
Posted By: eawedat Re: Socket's website connection - 19/11/11 02:31 PM
Riamus2
Php Code:

sockread %temptext
	if (%temptext != $null) {
	  echo -a %temptext
	}
 


still getting
/echo: insufficient parameters
Posted By: maroon Re: Socket's website connection - 19/11/11 06:08 PM
There are a few values that can still produce that error.

//var %x $chr(32) | echo -a %x

Change from
echo -a %temptext
to
echo -a $len(temptext) $asc(%temptext) %temptext
and see what happens
Posted By: eawedat Re: Socket's website connection - 19/11/11 06:33 PM
yea it works fine maroon but the thing is I do not like to show numbers beside lines which I think present length of line.

is there no another way?
Posted By: maroon Re: Socket's website connection - 19/11/11 06:52 PM
well you could put the control-o colour-code in front, that guarantees an output.

echo -a $chr(15) $+ %temptext

if your output has colours that you don't want to destroy, then a pair of control-r's will do it.

echo -a $+($chr(22),$chr(22),%temptext)
Posted By: eawedat Re: Socket's website connection - 19/11/11 07:56 PM
yes that worked! 100% is okay:)
what does chr(15) present? is it an empty char or what?

what about those :
Php Code:

HTTP/1.1 200 OK
Date: Sat, 19 Nov 2011 19:53:24 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Content-Length: 4480
Connection: close
Content-Type: text/html
 


How can I avoid them?

thanks.
Posted By: maroon Re: Socket's website connection - 19/11/11 07:59 PM
15 is the ascii char sent with a control-o, you can put any of the control-b/u/r/k/o colour codes inside the parenthesis for
echo -a $asc()
and see what the receiver sees as the ascii value for that code
Posted By: eawedat Re: Socket's website connection - 19/11/11 08:08 PM
ah I see , so what you have done is that you put a "hidden" char
that guarantees the output so if there is an empty line it still outputs to avoid error message with echo...nice trick :-)
it is better than to ask with conditions if(...!=$null)....
Posted By: CoLdFeAr Re: Socket's website connection - 20/11/11 02:34 AM
ice tried all the above code an all i get is

HTTP/1.1 200 OK
Date: Sun, 20 Nov 2011 02:32:22 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Sat, 19 Nov 2011 14:31:59 GMT
ETag: "5e0219-c2-4b21750f3f5c0"
Accept-Ranges: bytes
Content-Length: 194
Content-Type: text/html

Posted By: Tomao Re: Socket's website connection - 20/11/11 06:19 AM
Usage: /check
Code:
alias check {
  sockclose x
  sockopen x eawedat.zxq.net 80
}
on *:sockopen:x:{ 
  sockwrite -n x GET / HTTP/1.1 
  sockwrite -n x Host: eawedat.zxq.net
  sockwrite -n x
}
on *:sockread:x:{
  if ($sockerr) {
    echo -a Error
  }
  else {
    var %temptext
    sockread %temptext
    if ($regex(%temptext,/<title>(.+)<\/title>|$&
      $+ <a href="\S+">(.+)<\/a><\/font>|(.+\d{4} &copy;)/)) {
      echo -a $remove($replace($regml(1),&copy;,$chr(169)),$chr(9))
    }
  }
}
Output:
Quote:
Blog of Muhamad Eawedat - Wall
Info
CV
Works
Books
Story
Photos
Thanks
Blog's Birth
Contact Me
all rights reserved 2011 ©
Posted By: eawedat Re: Socket's website connection - 20/11/11 10:22 AM
Tomao , with your code -> in my situation it still outputs HTML Tags(All of Page's source)-I have already code to strip HTML tags but what we need to avoid those below

Php Code:

HTTP/1.1 200 OK
Server: Apache
Content-Length: 4480
Content-Type: text/html
 


thanks.
Posted By: Tomao Re: Socket's website connection - 20/11/11 05:45 PM
Why not show people the current script you have? And yes, it's very possible to escape the header fields from being shown.
Posted By: eawedat Re: Socket's website connection - 20/11/11 05:58 PM
Tomao , I did not understand your question about not showing people my script.. which script? the first one which I pasted above is my script ,,the first Reply of this Thread is my script.

2)How to escape the header fields?
Posted By: Tomao Re: Socket's website connection - 20/11/11 06:57 PM
My question was clear, unless I wrote a language other than English.

You mentioned you had the html tags stripped out, and that you'd like to avoid the header fields as I said in the last post. The example I showed you used regex, which matched the targeted strings you're after.

It's evident you want to keep the code the way you have, and I have nothing against that. Now, what you've posted in the original post is partial, not a complete code. I was basically asking you to show people what you have gotten so far, so it's easier to see is all.

Perhaps my English is still not understandable to you, so I'll see if someone who speaks perfect English can assist you further.
Posted By: eawedat Re: Socket's website connection - 20/11/11 09:15 PM
1)the regex you gave me did not hide the Header Fields.

2)"Now, what you've posted in the original post is partial, not a complete code. I was basically asking you to show people what you have gotten so far, so it's easier to see is all."

I still do not understand how do you assume that it is partial!
it is complete and I have no further code in addition to that.
it is so simple , there are no secrets to hide!
that was and is my complete script.
I mean at first my goal was only to show the source-code of a given website. then it became to show only Webpage's content without any additions either HTML's tags or Header Fields. and I do repeat that Regex did not help me out! still shows Header fields.
© mIRC Discussion Forums