DMPAPI(uint32_t) eeprom_read_dword (const uint32_t *__p) { uint32_t tmp; tmp = read_cmos((uint8_t) __p); // read 3rd high byte tmp = (tmp << 8) + read_cmos(((uint8_t) __p)+1); // read 2nd high byte tmp = (tmp << 8) + read_cmos(((uint8_t) __p)+2); // read 1st high byte tmp = (tmp << 8) + read_cmos(((uint8_t) __p)+3); // read low byte return tmp; }
DMPAPI(float) eeprom_read_float (const float *__p) { float tmp; unsigned char* p = (unsigned char*)&tmp; p[0] = read_cmos((uint8_t) __p); p[1] = read_cmos(((uint8_t) __p)+1); p[2] = read_cmos(((uint8_t) __p)+2); p[3] = read_cmos(((uint8_t) __p)+3); return tmp; }
unsigned char EEPROMClass::read(unsigned short int in_addr) { if(((in_addr >= EEPROMSIZE) && (_bank == EEPROM_16K)) || ((in_addr >= EEPROMSIZE_BANK0) && (_bank == EEPROM_200B)))//bank == true 0~16384, false 0~199 { Serial.print("EEPROMClass read error(bank = "); Serial.print(_bank); Serial.print("): in_addr = "); Serial.print(in_addr); Serial.print(" >= "); Serial.println(EEPROMSIZE); return 0; } if(_bank == EEPROM_200B) return read_cmos(in_addr); else return (_data[in_addr / DATASIZE])->read(in_addr - (DATASIZE * (in_addr / DATASIZE))); }
int main(int argc, char **argv){ unsigned char *buffer = calloc(0x100, sizeof(char)); unsigned char *password = calloc(0x7, sizeof(char)); int i; int dicloaded = 0; int verbose = 1; char *dicpath = malloc(0x20 * sizeof(char)); int read_and_exit = 0; // put the getopt thing up here. char opt; int lag = DELAY; while ((opt = getopt(argc, argv, "t:rqd:")) != -1){ switch (opt) { case 't': lag = atoi(optarg); break; case 'r': read_and_exit = 1; break; case 'q': verbose = 0; break; case 'd': strncpy(dicpath, optarg, 0x19); dicloaded = 1; break; default: break; //printf("USAGE MESSAGE goes here.\n"); } } if (ioperm(CMOS_ADDR, 2, 1)){ // ask permission (set to 1) for ports 0x70, 0x71 perror("ioperm"); exit (1); } printf( RED"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"COLOR_RESET " -=oO( CMOS DEBA5E12 )Oo=- \n" "Please wait while we dump your CMOS parameters.\n" RED"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"COLOR_RESET); read_cmos(buffer, verbose, lag); if (read_and_exit){ goto finish; } if (dicloaded){ goto cracker; } /* This part deals with the checksum. */ char ans; printf("CMOS CHECKSUM @ 0x%2.2x: 0x%2.2x\n", CHKSUM_INDEX, *(buffer + CHKSUM_INDEX)); printf("FLIP TO FORCE RESET (OR UNDO PRIOR FLIP) (y/N)? "); scanf("%c",&ans); if (ans == 'Y' || ans == 'y'){ outb(CHKSUM_INDEX, CMOS_ADDR); usleep(lag); outb(~(*(buffer + CHKSUM_INDEX)), CMOS_DATA); usleep(lag); printf("*** "RED"CHECKSUM INVERTED! CMOS[0x%2.2x] = 0x%2.2x "COLOR_RESET" ***\n", CHKSUM_INDEX, inb(CMOS_DATA)); } cracker: /* This part deals with the password. */ memcpy(password, (buffer + PSWD_INDEX), 6); printf("\nENCRYPTED PASSWORD AT BYTES 0x%2.2x TO 0x%2.2x: ", PSWD_INDEX, PSWD_INDEX + PSWD_LEN); for (i = 0; i < 6; i++) printf("%2.2x ",*(password+i)); printf("\n"); if (!dicloaded){ printf("To attempt to crack, enter path to dictionary file:\n>> "); scanf("%s", dicpath); } char cracked[16]; if (crack(cracked, password, dicpath) != 0){ printf("Sorry. The password has not been cracked.\n"); } else { printf(RED"EUREKA:"COLOR_RESET" %s\n", cracked); } /////////////////////////// finish: /* Tidy things up. */ if (ioperm(0x71, 2, 0)){ // we don't need perms anymore (set to 0) perror("ioperm"); exit(1); } free(password); free(buffer); exit (0); }
DMPAPI(void) eeprom_read_block (void *__dst, const void *__src, size_t __n) { uint8_t* _dst = (uint8_t*) __dst; for(int i=0; i<__n; i++) _dst[i] = read_cmos(((uint8_t) __src)+i); }
DMPAPI(uint16_t) eeprom_read_word (const uint16_t *__p) { uint16_t tmp; tmp = read_cmos((uint8_t) __p); // read high byte tmp = (tmp << 8) + read_cmos(((uint8_t) __p)+1); // read low byte return tmp; }
DMPAPI(uint8_t) eeprom_read_byte (const uint8_t *__p) { return read_cmos((uint8_t) __p); }