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 25 guests and 1 member online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Network Pen Testing
escaping restricted shell
EH-Net
May 25, 2013, 09:01:01 PM
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
>
Network Pen Testing
(Moderator:
don
) >
escaping restricted shell
Pages: [
1
]
2
Go Down
« previous
next »
Print
Author
Topic: escaping restricted shell (Read 9299 times)
0 Members and 1 Guest are viewing this topic.
wlandymore
Newbie
Offline
Posts: 34
escaping restricted shell
«
on:
March 15, 2012, 09:55:26 AM »
I'm doing online challenges to improve my skills. However, my latest one is stumping me.
They give you a username/password to login with ssh and then it puts you in a restricted shell. all commands are disabled except for 'tee' and 'ls'. I am able to run things like 'set IFS=/' and have it accept that, but anything like 'set PATH=/bin/sh' will fail because they are read only. I have managed to break out of the shell a few times by pasting arbitrary code in there, but it doesn't seem to work with any regularity. I have been Googling for what seems like days to try to find something that will work 100% of the time, but I haven't found anything yet.
I can't run 'man' and then try to break out because that's disabled. I can't run 'vi', 'scp', etc, etc.
Does anyone know a better way to make it out of a restricted shell? I'm stumped here.
Logged
tturner
Sr. Member
Offline
Posts: 432
Re: escaping restricted shell
«
Reply #1 on:
March 15, 2012, 01:55:45 PM »
How about
Code:
awk 'BEGIN {system("/bin/sh")}'
Not sure if you can use awk or not. If not, you could try using echo statements into a file to build a script to invoke /bin/sh with exec statements in Perl, Ruby, etc.
Another option is using less and more shell escapes using the !
Can you run sudo commands?
Logged
Certifications:
CISSP, CISA, GPEN, GWAPT, GAWN, GCIA, GCIH, GSEC, OPSE, CSWAE, CSTP, VCP
WIP: OSWP, GSSP-JAVA, GXPN
Udacity on hold, again. I suck.
http://sentinel24.com/blog
@tonylturner
http://bsidesorlando.org
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #2 on:
March 15, 2012, 08:14:01 PM »
Hey, thanks for responding.
sudo and awk give me the same: restricted: cannot specify `/' in command names
I can use the echo statements but I can't redirect them to a file because it will give me the "cannot redirect output" error. I have found a few things where it will accept commands like:
umask 0
IFS=/;export IFS
However, trying to set the PATH or SHELL variables fails, because they are read-only. I'm really new to this kind of thing so there is a limit to my knowledge.
I did a scan with OpenVAS and it found:
OpenSSH CBC Mode Information Disclosure Vulnerability, but when I looked for any exploit I couldn't find anything that would allow me to take advantage of that either.
Logged
TheXero
Full Member
Offline
Posts: 112
Try Harder!
Re: escaping restricted shell
«
Reply #3 on:
March 16, 2012, 04:38:37 AM »
wlandymore are you doing a hacking-lab.com challenge, ie 'got wurzel' or 'got root'?
These challenges I found quite hard (not complete 'got root' yet) but being able to break out of rbash is not something I have come across before.
Focus on what you can execute (in ~/bin) and and you should be able to break out of it fairly quickly
Logged
OSCP | OSWP
www.thexero.co.uk
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #4 on:
March 16, 2012, 08:26:32 AM »
yeah, those are the ones I'm doing. I was looking at the /bin folder underneath the restricted1 folder and there was only the ping, ls, and tee. Like I said, I've broken out a couple of times (probably from blind luck) but usually I'm wasting so much time breaking out that I don't have a way of elevating to root after that. Then if I try again the same sets of things that worked previously don't work. I even ran a script to try to brute-force the SSH login for root because I was grasping at straws but after I got through about 500 passwords of my file they cut me off.
I got through the level 2 decryption one pretty easily, but these ones I'm finding are quite hard even though they're level 1. I'm trying to get better at this stuff with the trial and error but this one seems a lot harder without any experience to go on.
Logged
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #5 on:
March 16, 2012, 08:44:18 AM »
Oh my gosh...that was easy. I totally didn't think of using the ~/bin. I was trying to edit the commands before with 'tee' but I was using the whole path like: /home/user/bin instead so it would always complain that I had a / in the path.
Thanks.
«
Last Edit: March 16, 2012, 08:59:33 AM by wlandymore
»
Logged
TheXero
Full Member
Offline
Posts: 112
Try Harder!
Re: escaping restricted shell
«
Reply #6 on:
March 16, 2012, 09:29:32 AM »
Many people attempt these boxes all day (they get reset on the hour) so just try again and see if you can do exactly the same again
Logged
OSCP | OSWP
www.thexero.co.uk
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #7 on:
March 16, 2012, 11:01:14 AM »
yeah, it was only about 10 minutes before it bumped me off and when I went back in it was back to default. I just ran the same thing editing the ping command with tee and it worked like a charm.
Now I can actually focus on exploiting the system instead of wasting all that time breaking out of the shell.
Thanks for the hint.
Logged
TheXero
Full Member
Offline
Posts: 112
Try Harder!
Re: escaping restricted shell
«
Reply #8 on:
March 16, 2012, 11:26:26 AM »
Privilege escalation can be one of the most challenging and exciting parts, so good luck
Logged
OSCP | OSWP
www.thexero.co.uk
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #9 on:
March 16, 2012, 09:10:40 PM »
thanks.
I've been compiling a lot of c exploits but I haven't been successful yet.
Logged
avinashs
Newbie
Offline
Posts: 2
Re: escaping restricted shell
«
Reply #10 on:
March 17, 2012, 02:20:00 PM »
Hey,I have a doubt.I started doing this lab work today and one thing that I couldn't figure out was, the ~/bin/ping is an executable and if we do
tee -a ~/bin/ping with /bin/sh
the /bin/sh is appended to ~/bin/ping as plain text rite.So it wont execute.Same thing happened to me.It didn't get executed.I am just a beginner.Did I miss anything obvious ?
Logged
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #11 on:
March 19, 2012, 02:00:59 PM »
yeah, you don't want to have the -a in there because that will just append it to what's already there.
However, if you run: tee ~/bin/ping
and then /bin/sh (then Ctrl+C to exit)
and then run: ping
You will pop out of the shell.
Logged
mulitia
Newbie
Offline
Posts: 1
Re: escaping restricted shell
«
Reply #12 on:
March 31, 2012, 03:57:33 AM »
Hope this helps:
for 7002 Got Wurzel?:
______________________
# tee ping
/bin/bash
[ctrl-c] -or- [ctrl-d]
# ping
for 7002 Got Root:
______________________
# tee .bashrc
PATH=/usr/bin
export PATH
[ctrl-d]
[logout/log back in]
# vi
[esc] :set shell=/bin/bash
[esc] :shell
have fun
Logged
wlandymore
Newbie
Offline
Posts: 34
Re: escaping restricted shell
«
Reply #13 on:
April 03, 2012, 10:22:54 PM »
Hey thanks. I finally found the answer to the first one and it's not actually an exploit that was required at all.
Now I'm trying to break the 'got root' one but not having the same luck.
«
Last Edit: April 09, 2012, 10:14:05 AM by wlandymore
»
Logged
TheXero
Full Member
Offline
Posts: 112
Try Harder!
Re: escaping restricted shell
«
Reply #14 on:
April 04, 2012, 03:03:03 AM »
The whole reason that I use Hacking-Lab is because of a lack of spoilers (no taking the easy way out) and actually learning something.
I'm sure many others here will agree that spoilers ruin the challenge and I personally do not agree with spoilers being given here.
Logged
OSCP | OSWP
www.thexero.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
Free Business and Tech Magazines and eBooks
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.