Browse files

added payload and shellcode macros, fixed some compiler warnings

  • Loading branch information...
1 parent 76a94a4 commit 9292637a4a2e0bfee5158dafb1fbf414a536c096 Jevin Sweval committed Oct 2, 2010
Showing with 40 additions and 16 deletions.
  1. +0 −2 default_payload.S
  2. +2 −1 dev_syscalls.h.S
  3. +1 −1 dump_lv2.S
  4. +2 −1 pl3_memcpy.h.S
  5. +1 −1 shellcode_panic.S
  6. +31 −7 tools/bin2header.c
  7. +3 −3 tools/dump_elfs_pcap_to_dir.c
View
2 default_payload.S
@@ -379,5 +379,3 @@ hook_path_end:
payload_end:
.org RESIDENT_PAYLOAD_OFFSET + RESIDENT_PAYLOAD_MAXSIZE
-// fill out to 3840 bytes
-.org 3840
View
3 dev_syscalls.h.S
@@ -22,4 +22,5 @@ syscall_6_peek:
syscall_7_poke:
std %r4, 0x00(%r3)
- blr
+ blr
+
View
2 dump_lv2.S
@@ -89,4 +89,4 @@ message:
payload_end:
// fill out to 3840 bytes
-.org 3840
+.org 3840
View
3 pl3_memcpy.h.S
@@ -22,4 +22,5 @@ pl3_memcpy:
bne pl3_memcpy
blr
-#endif /* __PL3_MEMCPY_H_S__ */
+#endif /* __PL3_MEMCPY_H_S__ */
+
View
2 shellcode_panic.S
@@ -2,4 +2,4 @@
li %r3, 0
li %r11, 255
sc 1
-.org 0x28
+.org 0x28
View
38 tools/bin2header.c
@@ -3,12 +3,19 @@
#include <stdio.h>
#include <string.h>
-static const char header[] = \
+static const char ifdef_guard_header[] = \
"#ifndef __%s__\n" \
- "#define __%s__\n\n" \
- "static const u8 %s[] = {\n ";
+ "#define __%s__\n\n";
-static const char footer[] = "\n};\n\n#endif\n";
+static const char ifdef_guard_footer[] = "\n#endif\n";
+
+static const char array_header[] = "static const u8 %s[] = {\n ";
+
+static const char array_footer[] = "\n};\n\n";
+
+static const char macro_header[] = "#define %s_macro \\\n ";
+
+static const char macro_footer[] = "\n";
int main(int argc, char **argv)
{
@@ -33,18 +40,35 @@ int main(int argc, char **argv)
return -3;
}
- fprintf(fo, header, argv[3], argv[3], argv[3]);
+ fprintf(fo, ifdef_guard_header, argv[3], argv[3]);
+ fprintf(fo, array_header, argv[3]);
+
+ idx = 0;
+ while ((r = fread(buf, 1, sizeof(buf), fi)) > 0) {
+ for (i = 0; i < r; i++) {
+ fprintf(fo, " 0x%.2x,", buf[i] & 0xff);
+ if (++idx % 8 == 0)
+ fprintf(fo, "\n ");
+ }
+ }
+
+ fprintf(fo, "%s", array_footer);
+
+ fseek(fi, 0, SEEK_SET);
+
+ fprintf(fo, macro_header, argv[3]);
idx = 0;
while ((r = fread(buf, 1, sizeof(buf), fi)) > 0) {
for (i = 0; i < r; i++) {
fprintf(fo, " 0x%.2x,", buf[i] & 0xff);
if (++idx % 8 == 0)
- fprintf(fo, "\n ");
+ fprintf(fo, " \\\n ");
}
}
- fprintf(fo, "%s", footer);
+ fprintf(fo, macro_footer);
+ fprintf(fo, ifdef_guard_footer);
fclose(fi);
fclose(fo);
View
6 tools/dump_elfs_pcap_to_dir.c
@@ -136,12 +136,12 @@ int main (int argc, char *argv[])
uint32_t thingy = be32_to_cpu (((uint32_t *)buf)[1]);
if (out) {
- printf ("File has %d bytes\n", ftell (out));
+ printf ("File has %ld bytes\n", ftell (out));
fclose (out);
out = NULL;
}
- snprintf (temp, sizeof(temp), "%0.8X%0.8X", hash, thingy);
+ snprintf (temp, sizeof(temp), "%08X%08X", hash, thingy);
snprintf (path, sizeof(path), "%s/%s.bin", argv[2], temp);
out = fopen (path, "wb");
if (out == NULL) {
@@ -165,7 +165,7 @@ int main (int argc, char *argv[])
fclose (in);
if (out) {
fseek (out, 0, SEEK_END);
- printf ("File has %d bytes\n", ftell (out));
+ printf ("File has %ld bytes\n", ftell (out));
fclose (out);
}

0 comments on commit 9292637

Please sign in to comment.