Jump to content

Remote Command Control


Delta
 Share

Recommended Posts

I don't know how many of you have rented a steam game server before but most of the hosts use the same admin panel. In the panel there is an option to automatically update the server files. When you select the option a pop-up window occurs and it will show you exactly what the updater outputs. I wanted to duplicate this in AutoIt and I did by allowing a user to connect to the server via web browser and control cmd prompt.

This project was to basically expand my knowledge a little since the whole script uses AutoIt, HTML, and Ajax and I have never used Ajax before. I'm going to slap a "works on my machine cert" on it because my friend kept getting a browser bug while helping me test this that I was unable to duplicate and fix. Also all the code is extremly messy.

Uses Kip's TCP UDF. (Included in the ZIP)

Most of the functions and code were taken and modified from Manadar's HTTP Server.

There are now two versions, a web client version and a telnet client version.

Web Client Version

- Features -

  • Access Cmd Promt from any device that has a web browser.
  • Requires username and password to access.
- Bugs -

  • Cls command does nothing.
Client screen shot

Posted Image

Telnet Client Version

- Features -

  • Access Cmd Prompt from telnet.
  • Multiple users control seprate cmd prompt sessions
  • Force users to start in a specific directory
  • Restrict users commands
  • Commands Logout, Quit, Exit will end a users session and log them out
  • Cmd Promt closes when a users session ends
- Bugs -

  • Cannot backspace.
  • Cls command does nothing.
- Notes -

  • Includes a Read me, READ IT.
  • If you don't wish to compile as a CUI remove the #NoTrayIcon line.
Change Log

Update [9-5-09]

Released telnet version

Update [9-1-09]

Requires username and password authentication to send any commands

data.html contains Manadar's Ajax fix.

Downloads

Posted Image

Posted Image

Old Version Stats

RemoteCmdControl.zip (7.31K)

Number of downloads: 45

Edited by Deltaforce229

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

dont work :D only writed Loading... and its all :D

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

Hi Deltaforce, thanks for the credits and using my code! :D

It's good to see it being used in the field.

Edit: It worked straight out of the box! I ran it and navigated to localhost:82 and done.

I had a minor problem with the AJAX refreshing the page constantly. I fixed it by only getting the new page once the current page has finished downloading:

data.html

<html>
  <head>
    <title></title>
    <script language="Javascript" type="text/javascript">
      var data_old;
      function ajaxFunction(){
        var xmlhttp;
        if (window.XMLHttpRequest){
          xmlhttp=new XMLHttpRequest();
        } else if (window.ActiveXObject){
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        } else {
          alert("Your browser does not support XMLHTTP!");
        }
        xmlhttp.onreadystatechange=function(){
          if(xmlhttp.readyState==4){
            if(xmlhttp.responseText != data_old){
              data_old = xmlhttp.responseText
              document.getElementById('cmdpage').innerHTML=xmlhttp.responseText;
              var objDiv = document.getElementById('cmdpage');
              objDiv.scrollTop = objDiv.scrollHeight;
            }
            setTimeout(ajaxFunction, 1)
          }
        }
        xmlhttp.open("GET","/innerdata.html",true);
        xmlhttp.send(null);
      }
      setTimeout(ajaxFunction, 1);
    </script>
  </head>
  <body bgcolor="black" id="cmdpage"> 
    <center><font face="Lucida Console" size="2" color="white">Loading...</font></center>
  </body>
</html>
Edited by Manadar
Link to comment
Share on other sites

Hey Manadar thank you very very much for both your HTTP script and for fixing mine :D

Updated the script with authentication and Manadars Ajax fix.

rapid2share and toader try the updated version. If that doesn't work post your browser specs. I only have Firefox 3 and IE8 so if your using something else I can't test it.

I'm also working on a Telnet version that will allow multiple simultaneous users to be logged on to their own sessions of cmd prompt.

Edited by Deltaforce229

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

Ah, I tested this in Google Chrome. Worked perfect.

I'm also working on a Telnet version that will allow multiple simultaneous users to be logged on to their own sessions of cmd prompt.

You can use sessions/cookies for this with HTTP. Can't give you a syntax example now, but shouldn't be too hard to whip up some PHP and scan for packets.
Link to comment
Share on other sites

I have never really messed with sessions for http connections. The only reason I can set them up with telnet is because telnet provides a constant connection where http doesn't.

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

That's exactly why sessions/cookies where invented. You can use it to match several connections to one browser. It works like this:

Client: (This is the first visit by the client)

GET /index.html HTTP/1.1

Host: www.foo.bar

Server: (Server sees that no cookies have been sent, so it sends a Set-Cookie. where foo is the name of the cookie and bar is the data.

HTTP/1.1 200 OK

Content-type: text/html

Set-Cookie: foo=bar

Client: (A new request and any following requests)

GET /index.html HTTP/1.1

Host: www.foo.bar

Cookie: foo=bar

Link to comment
Share on other sites

I have used cookies before in PHP and javascript. It's using them in AutoIt that I have never done before. I think javascript will be the easiest route in this application though. The first thing I need to do though is to clean up the code.

On a side note I'm almost done with the telnet code and I'll be posting that soon.

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

I feel like a jerk because I said I would have this stuff posted soon. Unfortunately I've gotten sick and it has become impossible to focus on anything. That being said, BrettF I was wondering if you could post a link to your script. I tried searching for it but my head just kinda shutdown :D

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

I feel like a jerk because I said I would have this stuff posted soon. Unfortunately I've gotten sick and it has become impossible to focus on anything. That being said, BrettF I was wondering if you could post a link to your script. I tried searching for it but my head just kinda shutdown :D

I think he posted it here: #668956
Link to comment
Share on other sites

@Deltaforce229:

Thank you. It works fine under Windows XP Russian. See result below (Russian).

To do it the users should just make in _CleanHtml body two actions:

Func _CleanHtml($sHtml)

$sHtml = Convert_FROM_DOS_CHARSET_TO_WINDOWS_CHARSET($sHtml)

$sHtml = Convert_FROM_WINDOWS_CHARSET_TO_UTF8($sHtml)

$sHtml = StringReplace($sHtml, " ", " ")

$sHtml = StringReplace($sHtml, "<", "<")

$sHtml = StringReplace($sHtml, ">", ">")

$sHtml = StringReplace($sHtml, @CRLF, @CRLF & "<br>")

Return $sHtml

EndFunc ;==>_CleanHtml

Func Convert_FROM_DOS_CHARSET_TO_WINDOWS_CHARSET($sHtml) is to convert from DOS locale to Windows locale

Func Convert_FROM_WINDOWS_CHARSET_TO_UTF8($sHtml) is to convert from Windows locale to UTF-8

Edited by Valery

The point of world view

Link to comment
Share on other sites

Thanks Manadar I'll start working on a new version as soon as I'm feeling better.

Valery I have never heard of those functions charset functions before are they part of a UDF?

Edited by Deltaforce229

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

  • 2 months later...

Released telnet version. See first post.

Seems to encounter a runtime array error when (logging in) the user enters a string that does not contain a space. This causes StringSplit($Clients[$hSocket][2], " ") to fail, and later an array element is accessed that doesn't exist. It's an easy fix though. I found that adding these four lines fixed the problem. See below.

Add the below lines AFTER line 109 (line109: $Clients[$hSocket][2] = StringReplace($Clients[$hSocket][2], @CRLF, "") )

If not StringInStr($Clients[$hSocket][2], " ") Then ;if there isn't a space, get the heck out, because stringsplit will fail and will cause a runtime array error
    _TCP_Send($hSocket, "- Invalid login string. Remember to separate username and password by one space." & @CRLF)
    Return 1
EndIf

Aside from that, it seems like a really good script. No other errors that I could find. It seems to work quite nicely.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...