{"action":"opened","issue":{"url":"https://api.github.com/repos/rapid7/metasploit-payloads/issues/147","repository_url":"https://api.github.com/repos/rapid7/metasploit-payloads","labels_url":"https://api.github.com/repos/rapid7/metasploit-payloads/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/rapid7/metasploit-payloads/issues/147/comments","events_url":"https://api.github.com/repos/rapid7/metasploit-payloads/issues/147/events","html_url":"https://github.com/rapid7/metasploit-payloads/issues/147","id":191858907,"number":147,"title":"Load bitmap or load Jpeg","user":{"login":"mehmetgoksu","id":20892888,"avatar_url":"https://avatars.githubusercontent.com/u/20892888?v=3","gravatar_id":"","url":"https://api.github.com/users/mehmetgoksu","html_url":"https://github.com/mehmetgoksu","followers_url":"https://api.github.com/users/mehmetgoksu/followers","following_url":"https://api.github.com/users/mehmetgoksu/following{/other_user}","gists_url":"https://api.github.com/users/mehmetgoksu/gists{/gist_id}","starred_url":"https://api.github.com/users/mehmetgoksu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mehmetgoksu/subscriptions","organizations_url":"https://api.github.com/users/mehmetgoksu/orgs","repos_url":"https://api.github.com/users/mehmetgoksu/repos","events_url":"https://api.github.com/users/mehmetgoksu/events{/privacy}","received_events_url":"https://api.github.com/users/mehmetgoksu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-27T12:31:23Z","updated_at":"2016-11-27T12:31:23Z","closed_at":null,"body":"this your function converting bitmap to array and ı want to use this array to see screenshot so how can ı load bitmap using the array? or in continue of this functon has convert jpeg to array ;so how to load jpeg to see screenshot ?ı am using windows\r\n` convert_bmp_and_send(HBITMAP hBmp, HDC hDC)\r\n\t{\r\n\t// data structures\r\n\tBITMAP bmp;\r\n\tPBITMAPINFO pbmi;\r\n\tWORD cClrBits;\r\n\tBITMAPFILEHEADER hdr;       // bitmap file-header \r\n\tPBITMAPINFOHEADER pbih;     // bitmap info-header \r\n\tLPBYTE lpBits;              // memory pointer \r\n\tDWORD dwTotal;              // total count of bytes \r\n\tDWORD cb;                   // incremental count of bytes \r\n\tBYTE *hp;                   // byte pointer \r\n\tDWORD s;\r\n\t\r\n\r\n\t// Convert to JPEG stuff\r\n\tunsigned char* buf_jpeg;\r\n\tunsigned long buf_jpeg_size = 0;\r\n\r\n\r\n\t// Retrieve the bitmap's color format, width, and height. \r\n\tif (!GetObject(hBmp, sizeof(BITMAP), ( LPVOID ) &bmp))\r\n\t\t// GetObject failed\r\n\t\treturn 0;\r\n\r\n\t// Convert the color format to a count of bits. \r\n\tcClrBits = ( WORD ) ( bmp.bmPlanes * bmp.bmBitsPixel );\r\n\tif (cClrBits == 1)\r\n\t\tcClrBits = 1;\r\n\telse if (cClrBits <= 4)\r\n\t\tcClrBits = 4;\r\n\telse if (cClrBits <= 8)\r\n\t\tcClrBits = 8;\r\n\telse if (cClrBits <= 16)\r\n\t\tcClrBits = 16;\r\n\telse if (cClrBits <= 24)\r\n\t\tcClrBits = 24;\r\n\telse cClrBits = 32;\r\n\r\n\t// Allocate memory for the BITMAPINFO structure. (This structure \r\n\t// contains a BITMAPINFOHEADER structure and an array of RGBQUAD \r\n\t// data structures.) \r\n\tif (cClrBits != 24)\r\n\t\tpbmi = ( PBITMAPINFO ) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * ( DWORD ) ( 1 << cClrBits ));\r\n\r\n\t// There is no RGBQUAD array for the 24-bit-per-pixel format. \r\n\telse\r\n\t\tpbmi = ( PBITMAPINFO ) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));\r\n\r\n\t// Initialize the fields in the BITMAPINFO structure. \r\n\r\n\tpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);\r\n\tpbmi->bmiHeader.biWidth = bmp.bmWidth;\r\n\tpbmi->bmiHeader.biHeight = bmp.bmHeight;\r\n\tpbmi->bmiHeader.biPlanes = bmp.bmPlanes;\r\n\tpbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;\r\n\r\n\tif (cClrBits < 24)\r\n\t\tpbmi->bmiHeader.biClrUsed = ( 1 << cClrBits );\r\n\r\n\t// If the bitmap is not compressed, set the BI_RGB flag. \r\n\tpbmi->bmiHeader.biCompression = BI_RGB;\r\n\r\n\t// Compute the number of bytes in the array of color \r\n\t// indices and store the result in biSizeImage. \r\n\tpbmi->bmiHeader.biSizeImage = ( pbmi->bmiHeader.biWidth + 7 ) / 8\r\n\t\t* pbmi->bmiHeader.biHeight * cClrBits;\r\n\r\n\t// Set biClrImportant to 0, indicating that all of the \r\n\t// device colors are important. \r\n\tpbmi->bmiHeader.biClrImportant = 0;\r\n\r\n\r\n\tpbih = ( PBITMAPINFOHEADER ) pbmi;\r\n\tlpBits = ( LPBYTE ) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);\r\n\r\n\r\n\r\n\tif (!lpBits)\r\n\t\t{\r\n\t\t// GlobalAlloc failed\r\n\t\t//printf(\"error: out of memory\\n\");\r\n\t\treturn 0;\r\n\t\t}\r\n\r\n\t// Retrieve the color table (RGBQUAD array) and the bits \r\n\t// (array of palette indices) from the DIB. \r\n\tif (!GetDIBits(hDC, hBmp, 0, ( WORD ) pbih->biHeight, lpBits, pbmi, DIB_RGB_COLORS))\r\n\t\t{\r\n\t\t// GetDIBits failed\r\n\t\t//printf(\"error: GetDiBits failed\\n\");\r\n\t\treturn 0;\r\n\t\t}\r\n\r\n\thdr.bfType = 0x4d42;        // 0x42 = \"B\" 0x4d = \"M\" \r\n\t\t\t\t\t\t\t\t// Compute the size of the entire file. \r\n\thdr.bfSize = ( DWORD ) ( sizeof(BITMAPFILEHEADER) +\r\n\t\t\t\t\t\t\tpbih->biSize + pbih->biClrUsed\r\n\t\t\t\t\t\t\t* sizeof(RGBQUAD) + pbih->biSizeImage );\r\n\thdr.bfReserved1 = 0;\r\n\thdr.bfReserved2 = 0;\r\n\r\n\t// Compute the offset to the array of color indices. \r\n\thdr.bfOffBits = ( DWORD ) sizeof(BITMAPFILEHEADER) +\r\n\t\tpbih->biSize + pbih->biClrUsed * sizeof(RGBQUAD);\r\n\r\n\ts = sizeof(BITMAPFILEHEADER);\r\n\ts = s + ( sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof(RGBQUAD) );\r\n\t// Copy the array of color indices into the .BMP file. \r\n\tdwTotal = cb = pbih->biSizeImage;\r\n\thp = lpBits;\r\n\r\n\ts = s + ( ( int ) cb );\r\n\r\n\tbuf = ( CHAR * ) malloc(s * sizeof(CHAR));\r\n\tmemcpy(buf, ( LPVOID ) &hdr, sizeof(BITMAPFILEHEADER));\r\n\tmemcpy(buf + sizeof(BITMAPFILEHEADER), ( LPVOID ) pbih, sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof(RGBQUAD));\r\n\tmemcpy(buf + sizeof(BITMAPFILEHEADER) + ( sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof(RGBQUAD) ), ( LPSTR ) hp, ( int ) cb);\r\n`\r\n\tcinfo.err = jpeg_std_error(&jerr);\r\n\tjpeg_create_compress(&cinfo);\r\n    cinfo.in_color_space = JCS_RGB; /* arbitrary guess */\r\n    jpeg_set_defaults(&cinfo);\r\n\r\n\tsrc_mgr = jinit_read_bmp(&cinfo); //Returns a cjpeg_source_ptr but is really bmp_source_ptr...\r\n\r\n\tsrc_mgr->input_buf = buf;  \r\n\tsrc_mgr->read_offset = 0;\r\n    /* Read the input file header to obtain file size & colorspace. */\r\n\r\n\tstart_input_bmp(&cinfo, src_mgr);\r\n\r\n    jpeg_default_colorspace(&cinfo);\r\n\t\r\n\t// TODO: accept options from the command line for grayscale and quality. \r\n\t/* Go GRAYSCALE */\r\n\t//jpeg_set_colorspace(&cinfo, JCS_GRAYSCALE);\r\n\t/* Quality */\r\n\tjpeg_set_quality(&cinfo, 50, FALSE);\r\n\r\n\t// Write the compressed JPEG to memory: bug_jpeg\r\n\tjpeg_mem_dest(&cinfo, &buf_jpeg, &buf_jpeg_size);\r\n\r\n    /* Start compressor */\r\n    jpeg_start_compress(&cinfo, TRUE);\r\n\r\n\t/* Process data */\r\n\twhile (cinfo.next_scanline < cinfo.image_height) {\r\n\t\tnum_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);\r\n\t\t(void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);\r\n\t}\r\n\t\r\n\t/* Finish compression and release memory */\r\n\t(*src_mgr->finish_input) (&cinfo, src_mgr);\r\n\tjpeg_finish_compress(&cinfo);\r\n\tjpeg_destroy_compress(&cinfo);\r\n\tpacket_add_tlv_raw(resp, TLV_TYPE_DEV_SCREEN, buf_jpeg, buf_jpeg_size);\r\n\t// Is it safe to free this right after pack_add_tlv_raw? \r\n\tfree(buf_jpeg);\r\n`\r\n\t`"}}
{"actor":{"display_login":"mehmetgoksu"}}