int initGL() { //初始化GLFW if (!glfwInit()) return -1; //创建窗口 window = glfwCreateWindow(640, 480, "Magic Cube", NULL, NULL); if (!window) { glfwTerminate(); return -2; } //让窗体环境正确 glfwMakeContextCurrent(window); //初始化GLEW if (glewInit() != GLEW_OK) return -3; initShader(); initCallBack(); //初始化Opengl的一些东西 glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); glfwSetWindowSize(window, 870, 512); return true; }
bool Server::init(unsigned short port) { if (!mServerTaskPool.init()) { std::cerr<<__FUNCTION__<<"("<<__LINE__<<"): mServerTaskPool init fail"<<std::endl; return false; } if (!MyBaseServer::init(port)) { std::cerr<<__FUNCTION__<<"("<<__LINE__<<"): MyBaseServer init fail"<<std::endl; return false; } if (!mClientTaskPool.init()) { std::cerr<<__FUNCTION__<<"("<<__LINE__<<"): mClientTaskPool init fail"<<std::endl; return false; return false; } if (!ServerMsgProcess::getInstance().start()) { std::cerr<<__FUNCTION__<<"("<<__LINE__<<"): ServerMsgProcess start fail"<<std::endl; return false; } XmlConfig::loadClientConfig("configure/clientAddress.xml", clientInfoList); for (auto iter : clientInfoList) { std::cout<<"ip: "<<iter.ip<<" id: "<<iter.id<<" port: "<<iter.port<<" type: "<<iter.type<<std::endl; newClient(iter.ip.c_str(), iter.port, iter.id, iter.type); } initCallBack(); return true; }
GUI::GUI(int argc, char** argv) { position p = phyEngine->getPositionBody(Body::Trunk); camera.set( p + vector3(0,0.1,0.5), p, vector3(0,1,0)); glutInit(&argc, argv); glutInitWindowSize(800, 800); glutInitWindowPosition(10,90); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutCreateWindow("Bird Simulator"); initCallBack(); initLight(); glutMainLoop(); // you could use Fl::run() instead }
//http://articles.sysprogs.org/kdvmware/kdcom.shtml //http://j00ru.vexillium.org/?p=405 //http://visi.kenshoto.com/static/apidocs/vstruct.defs.kdcom-module.html //https://code.google.com/p/reactos-mirror/source/browse/trunk/reactos/include/reactos/windbgkd.h int main(int argc, char* argv[]){ //printKD_PACKET((KD_PACKET_HEADER*)(unciphered_go+8)); //exit(0); //TODO: move this ! initCallBack(); int i; #if DEBUG printf("controlKey :\n"); for(i=0; i<32; i++){ printf("%02x ", controlKey[i]); } printf("\n"); #endif //Expand controlKey aes_key_setup(controlKey, controlW, 256); #if DEBUG printf("hmacKey :\n"); for(i=0; i<32; i++){ printf("%02x ", hmacKey[i]); } printf("\n"); #endif //Generate hmacKey from controlKey for(i=0; i<32; i++){ hmacKey[i] = controlKey[i]^0xFF; } if(argc == 2){ kd_server(); } // // //All my tests ! //--------------------- printf("\nPoke :\n"); //KDNET_PACKET_HEADER* poke_pkt = (KDNET_PACKET_HEADER*)poke; //printKDNET_PACKET(poke_pkt); BYTE* tmp = cbc_decrypt(poke+6, 0x160, controlW, poke+sizeof(poke)-16); uint8_t arf[2096]; memset(arf, 0, 2096); for(i=0; i<6; i++){ arf[i] = poke[i]; }; for(i=0; i<0x160-16; i++){ arf[i+6] = tmp[i]; } printf("\n\n"); for(i=0; i<0x166; i++){ printf("%02x ", arf[i]); if(i%16 == 15){ printf("\n"); } } printf("\n"); BYTE tmpSHA[32]; hmacSHA256Context myHmacSHA256Context; hmacSHA256Init(&myHmacSHA256Context, hmacKey, 32); hmacSHA256Update(&myHmacSHA256Context, arf, 0x166); hmacSHA256Final(&myHmacSHA256Context, tmpSHA); printf("\nChecksum:\n"); for(i=0; i<16; i++){ printf("%02x ", tmpSHA[i]); } printf("\n\n"); printf("\nPoke response :\n"); BYTE* unciphered_poke_resp = cbc_decrypt(poke_resp+6, sizeof(poke_resp)-6-16, controlW, poke_resp+sizeof(poke_resp)-16); BYTE dataKey[32]; SHA256Context mySHA256Context; SHA256Init(&mySHA256Context); SHA256Update(&mySHA256Context, controlKey, 32); SHA256Update(&mySHA256Context, unciphered_poke_resp+8, 322); SHA256Final(&mySHA256Context, dataKey); aes_key_setup(dataKey, dataW, 256); printf("\ndataKey :\n"); for(i=0; i<32; i++){ printf("%02x ", dataKey[i]); } printf("\n"); pcap_t *handle; char errbuf[PCAP_ERRBUF_SIZE]; //not sure what to do with this, oh well handle = pcap_open_offline("/home/arfarf/git/samples/debug_trace.pcap", errbuf); //call pcap library function const u_char *packet; // The actual packet struct pcap_pkthdr header; // The header that pcap gives us int pkt_num = 1; while ((packet = pcap_next(handle,&header))) { u_char *debug_pkt = (u_char *)packet+42; //cast a pointer to the packet data int debug_pkt_len = header.caplen-42; if(debug_pkt[5] == 0){//Only Data Packet BYTE *unciphered_debug_pkt = cbc_decrypt(debug_pkt+6, debug_pkt_len-6-16, dataW, debug_pkt+debug_pkt_len-16); KD_PACKET_HEADER* tmp = (KD_PACKET_HEADER*)(unciphered_debug_pkt+8); //if(tmp->ApiNumber == DbgKdContinueApi2){ if(pkt_num == 680 || pkt_num == 681){ printf("%d.\n", pkt_num); printHexData(unciphered_debug_pkt, debug_pkt_len-6-16); printKD_PACKET(tmp); printf("\n"); } } pkt_num++; } exit(0); printf("\nConnection Check :\n"); cbc_decrypt(conncheck+6, sizeof(conncheck)-6-16, dataW, conncheck+sizeof(conncheck)-16); printf("\nConnection Check response:\n"); cbc_decrypt(conncheck_resp+6, sizeof(conncheck_resp)-6-16, dataW, conncheck_resp+sizeof(conncheck_resp)-16); //... printf("\nPOKE (repeat):\n"); cbc_decrypt(poke_repeat+6, 0x160, controlW, poke_repeat+sizeof(poke_repeat)-16); //... printf("\n[!] Break :\n"); BYTE *unciphered_break = cbc_decrypt(break_data+6, sizeof(break_data)-6-16, dataW, break_data+sizeof(break_data)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_break+8)); printf("\n[!] Wait State :\n"); BYTE *unciphered_wait_state = cbc_decrypt(wait_state+6, sizeof(wait_state)-6-16, dataW, wait_state+sizeof(wait_state)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_wait_state+8)); printf("\n[!] Reset:\n"); BYTE *unciphered_reset = cbc_decrypt(reset+6, sizeof(reset)-6-16, dataW, reset+sizeof(reset)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_reset+8)); printf("\n[!] Reset ACK:\n"); BYTE *unciphered_reset_ack = cbc_decrypt(reset_ack+6, sizeof(reset_ack)-6-16, dataW, reset_ack+sizeof(reset_ack)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_reset_ack+8)); printf("\n[!] Wait State 2:\n"); BYTE *unciphered_wait_state2 = cbc_decrypt(wait_state2+6, sizeof(wait_state2)-6-16, dataW, wait_state2+sizeof(wait_state2)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_wait_state2+8)); printf("\n[!] Get Version API REQ :\n"); BYTE *unciphered_get_version_api_req = cbc_decrypt(get_version_api_req+6, sizeof(get_version_api_req)-6-16, dataW, get_version_api_req+sizeof(get_version_api_req)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_get_version_api_req+8)); printf("\n[!] Get Version API RESP :\n"); BYTE *unciphered_get_version_api_resp = cbc_decrypt(get_version_api_resp+6, sizeof(get_version_api_resp)-6-16, dataW, get_version_api_resp+sizeof(get_version_api_resp)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_get_version_api_resp+8)); exit(0); printf("\n[!] Read Virtual Memory API REQ\n"); BYTE *unciphered_read_virtual_memory_api_req = cbc_decrypt(read_virtual_memory_api_req+6, sizeof(read_virtual_memory_api_req)-6-16, dataW, read_virtual_memory_api_req+sizeof(read_virtual_memory_api_req)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_read_virtual_memory_api_req+8)); printf("\n[!] Read Virtual Memory API REQ ACK\n"); BYTE *unciphered_read_virtual_memory_api_req_ack = cbc_decrypt(read_virtual_memory_api_req_ack+6, sizeof(read_virtual_memory_api_req_ack)-6-16, dataW, read_virtual_memory_api_req_ack+sizeof(read_virtual_memory_api_req_ack)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_read_virtual_memory_api_req_ack+8)); printf("\n[!] Read Virtual Memory API RESP\n"); BYTE *unciphered_read_virtual_memory_api_resp = cbc_decrypt(read_virtual_memory_api_resp+6, sizeof(read_virtual_memory_api_resp)-6-16, dataW, read_virtual_memory_api_resp+sizeof(read_virtual_memory_api_resp)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_read_virtual_memory_api_resp+8)); uint32_t tmp_checksum = checksumKD_PACKET((KD_PACKET_HEADER*)(unciphered_read_virtual_memory_api_resp+8), sizeof(read_virtual_memory_api_resp)-6-16); printf("Checksum test : 00001ce3 %08x\n", tmp_checksum); printf("\n[!] Read Virtual Memory API RESP ACK\n"); BYTE *unciphered_read_virtual_memory_api_resp_ack = cbc_decrypt(read_virtual_memory_api_resp_ack+6, sizeof(read_virtual_memory_api_resp_ack)-6-16, dataW, read_virtual_memory_api_resp_ack+sizeof(read_virtual_memory_api_resp_ack)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_read_virtual_memory_api_resp_ack+8)); printf("\n[!] Next\n"); BYTE *unciphered_next = cbc_decrypt(next+6, sizeof(next)-6-16, dataW, next+sizeof(next)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_next+8)); exit(0); printf("Get Register RESP\n"); BYTE* unciphered_get_register_resp = cbc_decrypt(get_register_resp+6, sizeof(get_register_resp)-6-16, dataW, get_register_resp+sizeof(get_register_resp)-16); printKD_PACKET((KD_PACKET_HEADER*)(unciphered_get_register_resp+8)); //unciphered_break_ack = cbc_decrypt(cmd_data+6, sizeof(cmd_data)-6-16, dataW, cmd_data+sizeof(cmd_data)-16); //printKD_PACKET((KD_PACKET_HEADER*)(unciphered_break_ack+8)); return 0; }
AutoDragger::AutoDragger() { _draggingElement = NULL; _lastTime = 0; initCallBack(this, kCallBackAtExtremes); }