Online tool for Swiss Army knife Netcat

Source: Internet
Author: User
Tags telnet program

This is a noisy night, suppose to give a reason. Probably because although I think Spain is not pure, but how not to do for others to play the role of their own non-opera. After the end. I think it's time to play the netcat of the name of the Swiss Army Knife of the Internet.

Although the Swiss Army knife and Netcat in addition to small and fine aspects of not necessarily contact, but I still want to talk about the Swiss, I know the blog. Not a paper, not a test report, diverging a bit no problem, and, I think in the future. Cross-border will be a certain trend, the ability to have cross-border is also a certain advantage.

Switzerland is a country without history, it is the result of a 1848-year political compromise, which also shows why even Nazi Germany recognizes its permanently neutral state status, but it does not mean that the people living in this land have no history. Since the time of Caesar. There is a free nation living here. In the age of Gaolu, it developed itself under the atmosphere of the Roman. Then its history is a history of fusion, separation, struggle and neutrality, but it is undeniable that this land and the people of this land are in the middle of the chaotic medieval lords. King. Shinra Emperor, Pope. Bishop, municipality ... Survived in the fierce scuffle between, and did not become ruins. Until now. It's still one of the most affluent areas in the region, so look at the map. It's different from Belgium and Holland. Switzerland is in the midst of a big country. France. Germany. Italy. Austria's four strongest form the neighboring countries of Switzerland. It can see its history from its language. German. French, Italian (why not Austrian?) Because most of the Austrian people speak German, the sequela of the Divine Luo, this position is precisely in line with the principle of European equilibrium. That is why Switzerland is able to escape from the N-th Holocaust unscathed as a neutral state, and it is the principle of European balance of powers that creates a stable external environment for countries like Switzerland, which can refine the design and be able to compromise without external pressure, as the Swiss Army knife was built in such an environment. Of course, there are watches.

But let's say something else is more Shan.
What is it? That's the Nordic gene.

If I say that the Nordic gene has contributed to Linux, do you believe it? But no matter what. The Nordic gene does play a role. The Nordic, a descendant of a purely marine nation, a descendant of a nation unrelated to the Roman Empire. Break away from the shackles of European tradition. Far from the disputes left over from history, they live in a world of fairy tales and myths. It is perhaps the greatest trait of the marine race to harness the deep, unpredictable ocean and to sway freely and freely and with the primitive impulses of the rules.

Swiss Army Knife. A super gadget with Nordic genes, in line with its philosophy of outward self-consistent internal divergence, how to describe its beauty is only a point. The gene phenotype of northern Europe. Combined with small and refined pursuits. It is this trait that gives the Swiss army knife the same atmosphere as Linux ... Of course, the use of things does not mean that it is omnipotent. You can't expect it to cut off a crane's wire rope, nor do you fancy it can pry up a truck. In fact. The lack of these features is the beauty of the Swiss Army knife, that is, it is not chatty, but small and fine, sometimes small and fine philosophy can indeed win. The standard for evaluating a tool is not what it can do, but how easily it can do what it claims to do. With a Swiss army knife in your hand, you can save a lot of things, but you can build them with no gadgets. For example, a thermometer. Compass. Scissors, screwdriver, screwdriver, u disk, meter, toothpick. Winding coil ... The subtlety of design is how to put these things in a limited space, and how not to be misused by people, the simple way is that every gadget is just perfect for a function.

All right. This is the whole Swiss Army knife, the following is Netcat.
Netcat, very small, very small, and really small, rather than small, it is not like the Linux kernel, someone claims it can be cut to less than XK. But do you know how much effort it takes to cut people? Let's say that someone who has just graduated from a job soon will be cut. He probably just read some code during college, so how many classes does he have to add?

The good thing is not how small it can be, but the fact that it cannot be smaller. How small can the Netcat be? In fact, it just provides a socket IO channel, but don't look at the small collection of features it comes with. It does not even call it a collection, but it increases the scope of expansion to the extent of your imagination and to those who are not good at thinking. It may just be a telnet program, but for those who are good at thinking. It is able to build a secure remote shell. Have you ever thought of using it to build an SSL channel?
Before I start my exploration, I'll start with a brief overview of the features of the netcat that can be found on the web, and I'll stop repeating it here, and its function points include but are not limited to: detect if Port is on, port scan, remote copy file. Remote Copy folder, encrypt transfer data, run shell remotely, reverse remote shell ... Why is it that so little netcat can finish so many functions?
The reason for this is that it provides only the minimum set, which is an IO channel. As for how to build the data, that is not its responsibility, netcat does not assume that the data in any format. No matter what the constraints on the data, this is different from Telnet, although Telnet is a slightly more general TCP test program, but for the transmission of data it has a very wide range of formatting and assumptions, after all, it is the most beginning for remote login design, In fact, the above functions almost are not netcat finished, netcat just transfer data to the end only, that's all. It's a feat!

Just imagine, who is a remote telnet 23 or SSH must be TCP client actively initiate a connection to the TCP server? That is, what is the sshd to run on the TCP server side? In fact, no one rules. It's just a remote login. But that's the default behavior on this implementation. caused a lot of remote logins to fail, since these remote logins are from the extranet to the intranet. And very many firewalls do not agree to unsolicited visits from outside to inside. Using Netcat can do this, run a netcatclient in the intranet, run the Netcat server on the outside network. Then let the/bin/bash cover off the Netcat, this is the pioneering position. I'll say why.

       Suppose you run a netcat-e $pro . So after the connection is successful, do you think Netcat will call fork/exec like most programs to run Pro? Very many people will think so, because this is the standard practice of Unix tradition. But Netcat did not do so, but directly in the current NETCAT process exec a pro. This is so fierce. Now that the netcat disappears and is covered by pro, what happens next? Who's going to do the main control? In fact. Netcat gave the control to pro in this regard. Before the handover. REDIRECT the Stdin,stdout,stderr to your own socket. That's all. Netcat left is a socket IO channel. The next Pro program is stdin. Stdout,stderr is the socket. Besides. Netcat leaves no trace whatsoever, when running netcat 1234-e/bin/bash , the implication is as if you are running /bin/bash Socketstdin Socketstdout ... It is only a pity that Unix philosophy does not agree with/bin/bash such programs and sockets have no connection whatsoever. So just good use of another small program and its combination to simulate the local IO on the network, netcat in the E-parameter in addition to doing this, no matter what side effects. Suppose you don't want to completely stdin,stdout. StdErr are redirected, for example, you just want to redirect stdin. Then you will be able to combine symbols such as |,>,< and netcat, for example netcat-l-P 1234 <./transfile. Cat Transfile2 |netcat 2234 etc., in which case the netcat itself is still there and is not disappearing under the-e parameter. But it does not only do IO. Nothing is going to be done more. This is how the Swiss saber-like versatility comes in. Yes. It all lies in your imagination, you can no longer say, this function or the function of the netcat not provide, can not say, should say that you did not think of how it can be used. Assuming that I write Netcat's manual, I'll write a sentence: it provides and only provides a TCP or UDP network channel. It can achieve all the network functions using TCP or UDP protocol.

I want to implement a remote run command mechanism, do not want to program. Do not want to use SSH, how to do it? Using Netcat is very good, first it can implement a DH key exchange, and then encrypt the data to be transferred. Then decrypt, improvise a shell, and return the result after running the command. Encryption is returned, which is a cinch. Assuming you want to get an encrypted shell remotely, you need to do some work, or you can implement a self-loop pipeline. That is, the final standard output of the command sequence is directed to the standard input of the first command, i.e. Netcat 1234|decryto|/bin/bash| [Email protected], the last @ means that the standard output of Encryto is directed to the standard input of netcat, the socket, assuming that you do not want to do so. Then you use the following code sequence to hijack whatever a shell is already running on a TTY and then run the command after the capture return value is returned:

int fd = open ("/dev/pts/0", O_RDWR), IOCTL (FD,   tiocsti,   "L"), IOCTL (FD,   Tiocsti,   "s")   , IOCTL (FD, Tiocsti,   "\ n");
But no matter what you do, don't change netcat. Suppose you really want to change it, it is better to write a satisfying their own needs, because netcat there is nothing to change, you think of it as the following procedures can be:
Socket;listenaccept//Note. There is no multi-processing mechanism loop:read;write;loop;
Remember, building a big feature with existing gadgets is an art that netcat itself is not a Swiss army knife. It is more like the hilt and scabbard of the Swiss Army knife and can hold almost all the tools, small is more. The key is tolerance, big inclusiveness, natural restraint is the least. Netcat fully conforms to the UNIX philosophy.
Is there a Swiss army knife on the network programming tool? I think there is, that's the bio mechanism of OpenSSL. It abstracts the IO process, and netcat redirects the IO process similar. Suppose that netcat simulates a native environment in a network environment. Then bio can simulate the network environment in this machine. As far as OpenVPN is concerned. The data is written directly to the bio. Instead of writing directly to the socket, this is the opposite of the netcat process, which, in the absence of a network environment, wants to debug the network program. Then bio is a sharp weapon.
Six in the morning, Spain has been lost for some time, I am not a fanatical fan, is the underdog, it is said that tomorrow's Italy vs England will be very exciting.

Online tool for Swiss Army knife Netcat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.