I had to deal with a malicious script that was inserted into a website today and was sending out spam. Typically I have a few tools I run, but I couldn’t locate this particular infection. Time to take another angle, Exim logs. The following shows the most used script directories which will help narrow down the suspects substantially.
Posts Tagged: bash
Obviously, you can adjust the -n param in the head command to return the top 20 for example.
I needed to quickly rename a bunch of file extensions in a directory. This one liner made quick work of it:
basename, when given a file name and a extension spits out something like this:
Which we then use to append the proper extension (.jpg) in the example and done.
Recently I had a issue where I needed to clean up some disk utilization on a linux server. In order to find a list of larger files, I used the following find command from the root directory I want to recurse through:
As you can see, the -size switch is setting the minimum size to find at 50Mb. Another issue that I ran into was deleting a large amount of files at once using something like:
“Argument list too large” was the error. Apparently the list of files is too large for rm to handle. I found that there are a variety of methods to solve this, from using loops to split up the files into smaller groups, to recompiling the kernel. One of the simplest is to use the find command to delete the files it finds:
The list of files to get deleted can also be tuned so it does not delete all the files in the path:
PLAYTERM is intended to raise the skills of terminal CLI users, share their skills and inspire others.
PLAYTERM wants to push forward a new way of education, because terminalsessions are language-independent, extremely educative & entertaining.
Basically, PlayTerm lets you ‘look over’ a guru’s shoulder, helping to learn the concept in the video.
It may sound strange, but eventhough CLI stuff sounds like an isolated environment, it is an extremely social playground. Since the eighties, billions of users have helped eachother improving their skills, to get things done faster.
However, there was never a playground for sharing this live, but only peeking over the shoulder of your neighbour (or a *N*X screen -x session).
PLAYTERM wants to restore the actual ‘live’ feeling, which was once established in the BBS scene. There, the BBS’es system operators could ‘takeover’ a users’s session..and show him the way around, or teach him a new programming language.
Bad hax0rs! base64_decode is used by hackers frequently when they hijack a site to obfuscate their malicious code. This quick BASH one-liner will find files containing this evil function and lists them out:
I found a handy technique to find files modified between a specific date. In essence, we touch two temp files, setting the modified dates to the range we want to find:
Note the date is yyymmddtime.
Then we run the find command:
I recently wanted to locate a specific file recursively within my directory tree. A simple way to do this is to:
In this example, we would be searching for a .htaccess file, but this could be changed to any file name, and even use wildcards like *.php.
Show top CPU users:
One of my clients needs their vendor to be alerted when their Backup Exec service crashes. I wrote the following quick-n-dirty batch script intended to be ran as a cron job.
And the cron line would be something like this: