mochahochabeachside.com

Tag: Linux

Removing malicious code with perl and sed…

by on Feb.10, 2009, under Linux, One-liners

Today, I had an instance where a customer's site had been attacked with a code injection affected all of his .php files. In this case, it was an old vBulletin install that had several known exploits on milw0rm (proof you should update often) that caused it.

Fortunately, the code was injected as a single line, and was the same in every file, and had the added benefit of being on the top line of the file.  So, I could use abit of perl to remove it, and then a bit of sed magic to remove the blank line left by Perl (because for some reason, it didn't want to remove the newline).

(continue reading...)

Leave a Comment :, , , , more...

Testing Random Randomness…

by on Feb.10, 2009, under Scripts

A post at Manik 2.0 got me thinking on whether or not the $RANDOM variable in bash was really all that random.  So, I created a little test script.  It's quite simple.  It accepts a command line argument for number of loops. Then, each loop, it assigns a random number to $RANDTEST, and then compares $RANDTEST to $RANDOM. Since $RANDOM changes every time, it should never, ever match.

(continue reading...)

Leave a Comment :, more...

Watch load, free mem, swap used

by on Feb.09, 2009, under Watch Lines

Here's a watch line to watch load, free memory, and swap memory at 10 second intervals.  Ignore the judicious use of escaping in this, I was under a time crunch and needed to make it work properly.

watch --interval="10" "uptime | awk '{print \"Load: \"\$10\" \"\$11\" \"\$12}' && free -m | grep \"Mem\" | awk '{print \"Free: \"\$4}' && free -m | grep \"Swap\" | awk '{print \"Swap: \"\$3}'"

Remember, escapism is rarely beautiful.

Leave a Comment :, more...

Ubuntu compatibility

by on Feb.05, 2009, under Hardware

EDIT: Stupid thing was in the wrong mode USB Transfer mode. Apparently, though, there's not a good option on linux for MTP.

Getting my wife's Sandisk Sanza Fuze working under Ubuntu is proving to be a bitch.  So far, it's recognizing the Fuze as a drive, and is displaying the folders on the fuze...

...but it isn't displaying the files.

We've tried releasing and re-inserting the usb mods:
rmmod uhci_hcd
rmmod ehci_hcd
modprobe uhci_hc

That didn't work :(

Perhaps it'll dawn on my today as I sleep.

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...