Permalink
Browse files

Initial commit - Second try...

squashed a commit into the initial commit so i had to rebase and
 squash everything in between
  • Loading branch information...
0 parents commit a91e6a3e9a37afaf23d4db24a65213df689909f5 @kakaroto committed with Youness Alaoui Sep 21, 2010
Showing with 881 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +31 −0 Makefile
  3. +53 −0 bin2header.c
  4. +393 −0 default_payload.S
  5. +37 −0 default_shellcode.S
  6. +43 −0 dev_syscalls.h.S
  7. +144 −0 device6_kmod.h.S
  8. +98 −0 macros.h.S
  9. +1 −0 ps3toolchain
  10. +5 −0 shellcode_panic.S
  11. +73 −0 syscall36.h.S
@@ -0,0 +1,3 @@
+[submodule "ps3toolchain"]
+ path = ps3toolchain
+ url = git://github.com/ooPo/ps3toolchain.git
@@ -0,0 +1,31 @@
+B2HTARGET = bin2header
+CFLAGS = -Wall -O3
+
+CC = gcc
+PPU_CC = ppu-gcc
+PPU_OBJCOPY = ppu-objcopy
+
+
+HEADERS = default_shellcode.h \
+ default_payload.h
+
+PAYLOADS = default_shellcode.bin \
+ shellcode_panic.bin \
+ default_payload.bin \
+
+all: $(PAYLOADS) $(HEADERS)
+
+$(B2HTARGET): $(B2HTARGET).c
+
+%.o : %.S
+ $(PPU_CC) -c $< -o $@
+%.bin : %.o
+ $(PPU_OBJCOPY) -O binary $< $@
+%.h : %.bin $(B2HTARGET)
+ $(PWD)/$(B2HTARGET) $< $@ $(*F)
+
+# Target: clean project.
+clean:
+ rm -f *~ $(PAYLOADS) $(HEADERS) $(B2HTARGET)
+
+.PHONY: all clean
@@ -0,0 +1,53 @@
+/* raw2payload. Convert our raw PPC code into a fancy C header */
+
+#include <stdio.h>
+#include <string.h>
+
+static const char header[] = \
+ "#ifndef __%s__\n" \
+ "#define __%s__\n\n" \
+ "static const u8 %s[] = {\n ";
+
+static const char footer[] = "\n};\n\n#endif\n";
+
+int main(int argc, char **argv)
+{
+ char buf[256];
+ FILE *fi, *fo;
+ int i, idx, r;
+
+ if (argc < 4) {
+ fprintf(stderr, "Usage: %s <raw> <c header> <array name>\n", argv[0]);
+ return -1;
+ }
+
+ fi = fopen(argv[1], "r");
+ if (fi == NULL) {
+ perror(argv[1]);
+ return -2;
+ }
+
+ fo = fopen(argv[2], "w");
+ if (fo == NULL) {
+ perror(argv[2]);
+ return -3;
+ }
+
+ fprintf(fo, header, argv[3], argv[3], 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", footer);
+
+ fclose(fi);
+ fclose(fo);
+ fprintf(stdout, "Header %s generated.\n", argv[3]);
+ return 0;
+}
Oops, something went wrong.

0 comments on commit a91e6a3

Please sign in to comment.