I have a c++ server that use libssh to create a Linux shell. I send Linux commands from a javascript client application in a browser for example 'ls' or 'pwd' ecc ecc. to the c++ server by websockets, then I write the command in the libssh buffer followed by /n and a thread get the replay. I write the replay in a Json structure and by websockets again send it to the web client. Then I show the replay in a textarea and if the replay is plain ascii all is ok. Obviously replays to commands like nano doesn't work. So I would like javascript terminal emulators like Xterm. But every example connect it to socket.io or node.pty. I tried to use directly write but nothing is showed. How it's possible to connect Xterm.js to websockets or visualize a generic string?
xterm.js provides an 'addOn' that makes connecting to a websocket very easy. There is a very simplified example on this page that can help get you started, I believe.
https://xtermjs.org/docs/api/addons/attach/
Related
I am able to view the frames as they come through but I have yet to find a way to see how much data is actually being sent.
Here is the trick. You can use "tshark" to capture the data in/out from web-socket. Or you can use the graphical version of tshark called Wireshark. If you are wanting to print the capture via your progarm (java file) then you can do Runtime.execute("tshark command here"). This must be the one way. Web-socket is a TCP socket between server and client. Wireshark can easily to this.
I am currently attempting to implement a small telnet server which spawns a PTY on a connection from a client, and transmits the output of a small nCurses application to the client. I am working in ruby but the question is language-agnostic. My use case does not require users of the application to log into user accounts, so I would prefer not to delegate proper transmission of the screen to system tools such as telnetd.
Given a TCP connection, what are the requirements for transmitting a textual nCurses interface over telnet or ssh? What types of buffering or encoding are necessary for ensuring that screen refreshes on the client side appropriately render the application? This is obviously handled during a typical ssh session, however how is it done?
Thanks in advance.
You need to set the TERM, LINES and COLUMNS environment variables (which you get the correct values for by the NVT protocol). Then you are ready to go and simply spawn an ncurses applications (with your PTY as it's stdin/stdout obviously). You do not need to buffer or otherwise tamper with the character streams (other than in your NVT implementation).
Is there a program available that will allow me to interactively write HTTP stream data and send it to a server? Ideally I'm looking for a console app that will allow me to type or paste HTTP headers and body, send it to my server, and get the response headers and body back.
Does such a program already exist?
I'm running W7 64-bit with .NET 4.0.
if you change your mind and want a GUI app
http://code.google.com/p/rest-client/
or you can also use fiddler
Edit:
http://code.google.com/p/rest-client/ also supports commandline
Maybe telnet is an option for you? If it's not already installed on your machine, take a look at this guide from MS.
To connect to your server use it like this:
telnet www.myserver.de 80
After the connection is established, you can paste your HTTP GET reqests or what ever you like.
tinyget is a useful MSFT tool that will make simple get requests. You can store these requests in text files and stream them in.
I'd like to use ngrep and/or perl to monitor the incoming data stream on a socket, then, when the appropriate characters arrive, like in this case, the string "192.168.1.101:8080", input to the data stream a redirect to another ipaddress, such as "192.168.1.102"
Is this even possible?
Sure, thats possible.
Algorithm/application would require:
MiM listenning server (creating sockets session sockets)
hand-shake on MiM:
(best thing would be if there would be a text stream not binary protocol used)
recv from client, parse message then:
if IP comes in, open or use already opened socket to the target server/port
send message or rest of the message to target server
provide communication beteween client and target sever (operate as gateway)
recv() client or server and send() back to appropriate side
General advice:
operate on select() or epoll(), approach more advanced but better.
This can done easily in Perl.
Take a look at perldoc perlipc, IO::Socket and IO::Select for examples.
You might find Beej's Guide to Network Programming helpful, too. The examples are all in C, but Perl's networking API is pretty close to the C flavor.
F
Is there a way to monitor the FTP port so that I can know what commands my FTP application is sending to a FTP server?
I am using a closed-source FTP client application, which is not working with a closed-source FTP application server. The client and the server are not communicating well with each other, and I would like to find out why. I wish to reverse-engineer the client to see what commends the client are sending to the sever. I used a web test tool before that allowed me to monitor the content transferring through HTTP, but I can't seem to find such tool for FTP. I appreciate it if you can help me out, thanks.
Sounds like you need a packet sniffer - assuming your network admins/company policy allows it...I have used wireshark fairly successfully before.
The core FTP commands should be visible in the packets.
You can use the Wireshark application: http://www.wireshark.org/
It should have decent parsing capabilities for FTP as well as other protocols.
Can you configure a proxy with the client? Then you could install an ftp proxy server using the logging on that to see what's going on?
There's a proxy server for Linux here: http://frox.sourceforge.net/doc/FAQ.html
Paul.
Do you have access to ftp-server logs? Its likely those commands would be logged there.
If they aren't, your next option would be to configure the server to log them, if you have access.
If thats not an option or server does not log such things, then you have to go to either packet sniffer or a proxy, as suggested by previous posters.
On Unix, tcpdump might be your friend. Maybe you should first state which OS you're targeting, though.
If you have the ability (often requiring root access) to use a packet sniffer, tcpflow sniffing the TCP control channel will show you the commands and responses going back and forth in an easy-to-read format.
If you don't have such access, tools such as ktrace and strace will allow you to see all data read and written on the socket for this connection, though it will be a little work to extract it.
If you could tell us just what tool you were using for HTTP traffic, that would allow us to look for something similar for FTP traffic.