0
I Use This!
Activity Not Available

Project Summary

iclickboot source code

/ 1ClickBoot - Utility for DFU, WTF and Recovery Copyright (C) 2008 wEsTbAeR--, tom3q This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . /

#include #include #include #include "usb.h" #define DFU_MODE 0x1222 #define WTF_MODE 0x1227 #define RECOVERY_MODE 0x1281 #define VERSIONNMBR "1.1" #define OWNIBSS "files\\0wniBSS.bin" #define OWNEDLLB "files\\LLB-0wned.img3" #define BSS211 "files\\iBSS211.dfu"

int verbose = 0; / A helper function dumping c bytes of a. void iHexDump(char a, int c) { if(verbose) {
int b;
for(b=0;bif(b%16==0&&b!=0)
printf("\n");
printf("%2.2X ",ab);
}
printf("\n");
}
}

/ A helper function initializing libusb and finding our iPhone/iPod which has given DeviceID struct usb_dev_handle iUSBInit(int devid) { struct usb_dev_handle devPhone = 0;
struct usb_device dev;
struct usb_bus bus;

usb_init();
usb_find_busses();
usb_find_devices();
if(verbose) printf("Got USB\n");
for(bus = usb_get_busses(); bus; bus = bus->next) {
//printf("Found BUS\n");
for(dev = bus->devices; dev; dev = dev->next) {
//printf("\t%4.4X %4.4X\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
if(dev->descriptor.idVendor == 0x5AC && dev->descriptor.idProduct == devid) {
// z0mg!!!! iPhone 4th Generation
// printf("Found iPhone/iPod in DFU 2.0\n"); devPhone = usb_open(dev);
}
}
}

return devPhone;
}

/ A helper function closing the USB connection void iUSBDeInit(struct usb_dev_handle devPhone) { if(verbose) printf("Closing USB connection...\n");
usb_close(devPhone);
}

void iSendFile(char filename);

/ Main function of -s mode void iSendCommand(char command) { struct usb_dev_handle devPhone;
int ret, length, skip_recv;
char buf, sendbuf, cmd, response;

devPhone = iUSBInit(RECOVERY_MODE);
if(devPhone == 0) {
printf("No iPhone/iPod found.\n");
exit(EXIT_FAILURE);
}
if((ret = usb_set_configuration(devPhone, 1)) < 0)
printf("Error %d when setting configuration\n", ret);
if((ret = usb_claim_interface(devPhone, 1)) < 0)
printf("Error %d when claiming interface\n", ret);
if((ret = usb_set_altinterface(devPhone, 1)) < 0)
printf("Error %d when setting altinterface\n", ret);
buf = malloc(0x10001);
sendbuf = malloc(160);
cmd=command;
if(verbose) printf("Executing command: %s\n", command);
length = (int)(((strlen(cmd)-1)/0x10)+1)0x10;
memset(sendbuf, 0, length);
memcpy(sendbuf, cmd, strlen(cmd));
if(!usb_control_msg(devPhone, 0x40, 0, 0, 0, sendbuf, length, 1000)) {
printf("[ ERROR ] %s", usb_strerror());
}
usb_release_interface(devPhone, 0);
free(buf);
free(sendbuf);
iUSBDeInit(devPhone);
}

/ Main function of -f mode void iSendFile(char filename) { struct usb_dev_handle devPhone;
FILE file;
int packets, len, last, i, a, c, sl;
char fbuf, buf6;
if(!filename)
return;

file = fopen(filename, "rb");
if(file == NULL) {
printf("File %s not found.\n", filename);
exit(EXIT_FAILURE);
}
fseek(file, 0, 0);
fclose(file);
devPhone = iUSBInit(WTF_MODE);
if(!devPhone) {
devPhone = iUSBInit(RECOVERY_MODE);
if(devPhone)
if(verbose)printf("Found iPhone/iPod in Recovery mode\n");
} else {
if(verbose)printf("Found iPhone/iPod in DFU/WTF mode\n");
}
if(!devPhone) {
printf("No iPhone/iPod found.\n");
exit(EXIT_FAILURE);
}
if(usb_set_configuration(devPhone, 1))
printf("Error setting configuration\n");
printf("\n");
file = fopen(filename, "rb");
fseek(file, 0, SEEK_END);
len = ftell(file);
fseek(file, 0, 0);
packets = len / 0x800;
if(len % 0x800)
packets++;
last = len % 0x800;
if(verbose)printf("Loaded image file (len: 0x%x, packets: %d, last: 0x%x).\n", len, packets, last);
fbuf = malloc(packets 0x800);
if(!last)
last = 0x800;
fread(fbuf, 1, len, file);
fclose(file);
if(verbose)printf("Sending 0x%x bytes\n", len);
for(i=0, a=0, c=0; isl = 0x800;
if(i == packets-1)
sl = last;
if(verbose) printf("Sending 0x%x bytes in packet %d... ", sl, c);
if(usb_control_msg(devPhone, 0x21, 1, c, 0, &fbufa, sl, 1000)) {
if(verbose) printf(" OK\n");
} else{
if(verbose) printf(" x\n");
}
if(usb_control_msg(devPhone, 0xA1, 3, 0, 0, buf, 6, 1000) != 6){
printf("Error receiving status!\n");
} else {
iHexDump(buf, 6);
if(buf4!=5)
printf("Status error!\n");
}
}
if(verbose)printf("Successfully uploaded file!\nExecuting it...\n");
usb_control_msg(devPhone, 0x21, 1, c, 0, fbuf, 0, 1000);
for(i=6; i<=8; i++) {
if(usb_control_msg(devPhone, 0xA1, 3, 0, 0, buf, 6, 1000) != 6){
printf("Error receiving status!\n");
} else {
iHexDump(buf, 6);
if(buf4!=i)
printf("Status error!\n");
}
}
free(fbuf);
iUSBDeInit(devPhone);
}

/ Shows the Arguments of the application. int iShowUsage(void) { printf("1ClickBootargs\n");
printf("\t -v \t\t\t Executes 1ClickBoot in verbose mode");
printf("\t -h \t\t\t Shows this help");
} / Resets the ipod void iCheck(int mode) { struct usb_dev_handle devPhone;
if(verbose) printf("Checking for device \n");
do {
if (mode == 0) {
devPhone = iUSBInit(WTF_MODE);
if(!devPhone) {
printf(".");
Sleep(2000);
}
}else if (mode == 1) {
Sleep(1000);
devPhone = iUSBInit(RECOVERY_MODE);
}
} while (devPhone == 0);
iUSBDeInit(devPhone);
printf("\n");
}

void iReset(void){ struct usb_dev_handle devPhone;
if(verbose)printf("Preparing for resetting device \n");
devPhone = iUSBInit(WTF_MODE);

if(!devPhone) {
printf("No iPhone/iPod found.\n");
exit(EXIT_FAILURE);
}
if(usb_set_configuration(devPhone, 1)) printf("Error setting configuration\n");
if(verbose)printf("Resetting Device NOW!\n");
usb_reset(devPhone);
if(devPhone) iUSBDeInit(devPhone);
}

/ Boots a Jailbroken ipod void iBoot(void) {

printf("\nWaiting for an Ipod in DFU mode...\n\n");
iCheck(0);
printf("\nSending original iBSS from 2.1.1 fw\n\n");
iSendFile(BSS211);
printf("\nResetting the USB connection\n\n");
iReset();
iCheck(1);
printf("\nSending 0wniBSS\n\n");
iSendFile(OWNIBSS);
printf("\nStarting the arm7 processor\n\n");
iSendCommand("arm7_go");
printf("\nStopping the arm7 processor\n\n");
iSendCommand("arm7_stop");
printf("\nSending the 0wned 2.2.1 LLB\n\n");
iSendFile(OWNEDLLB);
printf("\nRun the 0wned LLB\n\n");
iSendCommand("go");
}

/ Main function of the application int main(int argc, char argv[]) { printf("1ClickBoot %s by Yohurt \n", VERSIONNMBR);
printf("Based on iRecovery by wEsTbAeR and Tom3q\n");
printf("-v for verbose\n");
printf("-h for help\n\n\n");
if(argc < 2) {
iBoot();
} else if(strcmp(argv1, "-v") == 0) {
verbose=1;
iBoot();
} else if(strcmp(argv1, "-h") == 0) {
verbose=1;
iShowUsage();
}
return 0;
}

Tags

No tags have been added

In a Nutshell, 1clickbootcode...

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

GNU General Public License v3.0 or later
Permitted

Place Warranty

Use Patent Claims

Commercial Use

Modify

Distribute

Forbidden

Sub-License

Hold Liable

Required

Distribute Original

Disclose Source

Include Copyright

State Changes

Include License

Include Install Instructions

These details are provided for information only. No information here is legal advice and should not be used as such.

All Licenses

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    Black Duck offers a free trial so you can discover if there are open source vulnerabilities in your code
  • ...
    check out hot projects on the Open Hub
  • ...
    nearly 1 in 3 companies have no process for identifying, tracking, or remediating known open source vulnerabilities
  • ...
    data presented on the Open Hub is available through our API

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

Community Rating

Be the first to rate this project
Click to add your rating
   Spinner
Review this Project!
Sample ohloh analysis