Skip to content

Commit 62a2d29

Browse files
authored
Merge pull request #11 from JustinZYen/SMCxDeathBurger-Use-This-One
Public test case that doesn't segfault
2 parents c843c02 + 9d9dbb6 commit 62a2d29

9 files changed

Lines changed: 134 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Bugs often rear themselves in sparcely-maintained, but prominently used infrastructure.
2+
Often, such infrastructure takes the form of small, little-known libraries handling specific functionality for larger, well-known projects.
3+
One such example is [libcue](https://github.com/lipnitsk/libcue) and [CVE-2023-43641](https://github.blog/security/vulnerability-research/coordinated-disclosure-1-click-rce-on-gnome-cve-2023-43641/).
4+
5+
In real life, the actual attack vector was a part of gnome.
6+
Here, we've provided the `parse_cue` program.
7+
Understand this bug, understand the software around it, and trigger the crash.
8+
If you can segfault `parse_cue` (when invoked via `/challenge/check`), you will earn the flag!
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ubuntu:24.04
2+
RUN apt-get update && apt-get install -y autotools-dev autoconf libtool automake pkg-config make git python3
3+
ADD --chown=0:0 --chmod=6755 http://github.com/pwncollege/exec-suid/releases/latest/download/exec-suid /usr/bin/exec-suid
4+
COPY parse_xsd.c crash_to_flag.c /challenge/
5+
RUN mkdir -p /challenge/bin;\
6+
cd /challenge;\
7+
git clone https://github.com/GNOME/libxml2 ./libxml;\
8+
git config --global user.email "you@example.com";\
9+
git config --global user.name "Your Name";\
10+
git -C libxml revert e4f85f1bd2eb34d9b49da9154a4cc3a1bc284f68;\
11+
git -C libxml diff HEAD^ > /challenge/patch.diff;\
12+
cd /challenge/libxml;\
13+
./autogen.sh;\
14+
./configure --prefix=/challenge;\
15+
make -j$(nproc);\
16+
make -j$(nproc) check;\
17+
make -j$(nproc) install;\
18+
rm /challenge/bin/*;\
19+
gcc -I/challenge/include/libxml2 -o /challenge/bin/parse_xsd /challenge/*.c -L/challenge/lib -lxml2;\
20+
chmod 6755 /challenge/bin/parse_xsd
21+
22+
COPY run.sh /challenge/run
23+
RUN chmod 6755 /challenge/run
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <sys/stat.h>
2+
#include <unistd.h>
3+
#include <signal.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
#include <fcntl.h>
7+
#include <stdio.h>
8+
9+
void handle_crash(int signum)
10+
{
11+
puts("You crashed it! Here is your flag:");
12+
char flag[1024] = {0};
13+
int fd = open("/flag", O_RDONLY);
14+
if (fd < 0)
15+
{
16+
perror("unable to open /flag");
17+
exit(1);
18+
}
19+
read(fd, flag, 1024);
20+
puts(flag);
21+
chmod("/flag", 0644);
22+
close(fd);
23+
exit(-11 & 0xff);
24+
}
25+
26+
__attribute__((constructor)) void register_crash_flag_handler()
27+
{
28+
stack_t ss;
29+
ss.ss_sp = malloc(SIGSTKSZ);
30+
ss.ss_size = SIGSTKSZ;
31+
ss.ss_flags = 0;
32+
if (sigaltstack(&ss, NULL) == -1) {
33+
perror("sigaltstack");
34+
exit(1);
35+
}
36+
37+
struct sigaction sa = { 0 };
38+
sa.sa_handler = handle_crash;
39+
sa.sa_flags = SA_ONSTACK;
40+
41+
sigaction(SIGSEGV, &sa, NULL);
42+
sigaction(SIGILL, &sa, NULL);
43+
sigaction(SIGBUS, &sa, NULL);
44+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "base_templates/crash_to_flag.c" %}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <libxml/xmlschemas.h>
2+
#include <libxml/parser.h>
3+
#include <stdio.h>
4+
#include <string.h>
5+
#include <unistd.h>
6+
#include <fcntl.h>
7+
8+
int main(int argc, char* argv[]) {
9+
if (argc < 2) {
10+
fprintf(stderr, "Usage: %s <schema.xsd>\n", argv[0]);
11+
return 9001;
12+
}
13+
// Make sure we're not doing something dumb like sending in the flag
14+
int schema_fd = open(argv[1],O_RDONLY);
15+
char schema_smallbuff[13] = {0};
16+
read(schema_fd,schema_smallbuff,12);
17+
if (strncmp(schema_smallbuff,"pwn.college{",12) == 0) {
18+
printf("NO CHEATING\n");
19+
close(schema_fd);
20+
return 1;
21+
}
22+
close(schema_fd);
23+
// Load the crafted schema
24+
xmlSchemaParserCtxtPtr ctxt = xmlSchemaNewParserCtxt(argv[1]);
25+
xmlSchemaPtr schema = xmlSchemaParse(ctxt);
26+
27+
// Free resources, if we got this far
28+
xmlSchemaFree(schema);
29+
xmlSchemaFreeParserCtxt(ctxt);
30+
return 0;
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
export LD_LIBRARY_PATH=/challenge/lib:$LD_LIBRARY_PATH
3+
exec /challenge/bin/parse_xsd "$@"
606 Bytes
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh -e
2+
cat > /tmp/pass.xsd << 'EOF'
3+
<?xml version="1.0"?>
4+
5+
<xs:schema xmlns:xs="pwn.college">;
6+
<xs:complexType name="Hackers">
7+
<xs:sequence/>
8+
</xs:complexType>
9+
10+
<xs:complexType name="Hello">
11+
<xs:complexContent>
12+
<xs:extension base="Hackers">
13+
<xs:attribute name="bar" type="xs:int" use="optional"/>
14+
</xs:extension>
15+
</xs:complexContent>
16+
</xs:complexType>
17+
18+
</xs:schema>
19+
EOF
20+
21+
/challenge/run /tmp/pass.xsd
22+
23+

0 commit comments

Comments
 (0)