problem with http request

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: myhyli (myhyli_at_hotmail.com)
Date: 10/11/04


Date: Mon, 11 Oct 2004 17:54:09 +0800

I want to get some files from another remote server,so:

1.at first, I use xmlhttp(activeXObject),but I found it will not work with
some url like: http://rss.xinhuanet.com/rss/it.xml , and some url can,like:
http://rss.chinabyte.com/216454257090494464.xml (BUT I can access those url
correctly by IE)

I don't know why,and I don't think anything wrong with the program
so I decide to use another method

2.I use .net WebRequest class to do the same thing,but I got the same
result: failed with some url

what can I do?so at last, I think I have no choise but to use sockets

3.I use .net System.Net.Sockets to create an TcpClient to connect the the
HTTP server. This time I failed with any url :( . the remote http server
returned "400 bad request". I'm so unlucky!

the code here:
////////////////////////////////////////////////////////////////////////////
//////
<%@ page language="JScript" Debug="true" contenttype="text/plain"%>
<%@ Import Namespace="System.Net.Sockets" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Object" %>
<%
 var server = "www.blogchina.com";
 var file = "/xml/1_rss2.xml";
 var port = "80";

 var outputStr = [];
 var cmdMultiLine = [];

var t = new Date();

 init();

 function init(){

  //connect to HTTP server
  var tcpClient = new TcpClient();
  tcpClient.Connect(server, port);

  //get stream
  var netStream = tcpClient.GetStream();
  var readStream = new StreamReader(netStream,Encoding.GetEncoding(936));

  cmdMultiLine[cmdMultiLine.length] = "GET /xml/1_rss2.xml HTTP/1.0";
  cmdMultiLine[cmdMultiLine.length] = "Accept: */*";
  cmdMultiLine[cmdMultiLine.length] = "Accept-Language: zh-cn";
  cmdMultiLine[cmdMultiLine.length] = "Accept-Encoding: gzip, deflate";
  cmdMultiLine[cmdMultiLine.length] = "User-Agent: Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.0; MyIE2)";
  cmdMultiLine[cmdMultiLine.length] = "Host: www.blogchina.com";
  cmdMultiLine[cmdMultiLine.length] = "Connection: Keep-Alive";
  cmdMultiLine[cmdMultiLine.length] = "Cache-Control: no-cache";
  cmdMultiLine[cmdMultiLine.length] = "Cookie:
ASPSESSIONIDCSDBRDBB=BEOEIOCAGCMBKIHMDFOKIGLI\r\n\r\n";

  var cmd =
Encoding.GetEncoding("ascii").GetBytes(cmdMultiLine.join("\r\n").ToCharArray
());
  netStream.Write(cmd,0,cmd.Length);

  var read = new Char[256];
  var count = readStream.Read( read, 0, 256 );
  while (count > 0){
   var str = new System.String(read, 0, count);
   outputStr[outputStr.length] = str;
   count = readStream.Read(read, 0, 256);
  }

  netStream.Close();
  tcpClient.Close();
 }

%>

<% = outputStr.join("\r\n") %>
<!--<%=(new Date()-t)%>-->

////////////////////////////////////////////////////////////////////////////
//

thanks in advance



Relevant Pages

  • Mambo 4.6.3 Path Disclosure, XSS , XSRF, DOS
    ... # Title: Mambo Vulnerabilities ... Mambo is an, open source, modular, web content management system, written in Php with a MySql database in backend. ... var url = 'http://localhost/MamboV4.6.2/administrator/index2.php '; ... If an administrator follows up the above instruction,its possible for a remote attacker to remove any file from the remote server for example the main configuration file, which could result in remote denial of service! ...
    (Bugtraq)
  • RE: Authentication on remote machine
    ... HTA works now is if I'm logged onto the remote computer via RDP. ... var objWbemService = objWbemLocator.ConnectServer(g_strBuildMachine, ...
    (microsoft.public.win32.programmer.wmi)
  • Re: problem with http request
    ... If you can show us the code you have for using the WebRequest, ... >3.I use .net System.Net.Sockets to create an TcpClient to connect the the ... >HTTP server. ... > var server = "www.blogchina.com"; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Hi
    ... JRS: In article, ... dated Thu, 10 Aug 2006 04:38:10 remote, seen in ... var myStr=aIpAddress.toString; ... Your RegExp does not work in all JS browsers. ...
    (comp.lang.javascript)
  • MULTPLE REMOTE VULNERABILITIES --ProjectCMS v-1.1 Beta-->
    ... CMS INFORMATION: ... Var Vuln: GET var "file" ... SHELL UPLOAD/ARBITRARY IMAGE UPLOAD: ... REMOTE DIRECTORY DISCLOSURE: ...
    (Bugtraq)