ZIPThis is a page for ZIP file analysis (Header). Try sample file: Try an example
What are we looking for?For a ZIP file, we look for the byte sequence 504B0304 or the ASCII sequence of PK.. File contents analysisStarting tag (should be 0x504b0304): 504B0304 File signature analysis (Header analysis)ZIP file (Starts with 0x50 0x04B)Additional scanning signature analysisPossible: [ZIP files, sig: 504B03] Count: 1 File hex characters[00000000] 50 4B 03 04 14 00 00 00 08 00 B6 A3 2B 36 C9 7C PK..........+6.| Base-64 conversionUEsDBBQAAAAIALajKzbJfCfzeAMAANYEAAAIAAAAY2VydC5wN2JllEtzozgUhfdU8R9mn0pF |
Sample code
public string getZip(System.IO.Stream file) { /* 0 4 Local file header signature = (read as a little-endian number) 4 2 Version needed to extract (minimum) 6 2 General purpose bit flag 8 2 Compression method 10 2 File last modification time 12 2 File last modification date 14 4 CRC-32 18 4 Compressed size 22 4 Uncompressed size 26 2 File name length (n) 28 2 Extra field length (m) 30 n File name 30+n m Extra field */ string TextBox1 = ""; byte[] b = ReadFully(file, file.Length); TextBox1 = "Starting tag (should be 0x504b0304): " + Global.intToHex(b[0]) + Global.intToHex(b[1]) + Global.intToHex(b[2]) + Global.intToHex(b[3]) + "<br/>"; TextBox1 += "Version: " + Global.intToHex(b[4]) + " " + Global.intToHex(b[5]) + "<br/>"; TextBox1 += "General purpose bit flag: " + Global.intToHex(b[6]) + " " + Global.intToHex(b[7]) + "<br/>"; TextBox1 += "Compression method: " + Global.intToHex(b[8]) + " " + Global.intToHex(b[9]) + "<br/>"; TextBox1 += "File last modification time: " + Global.intToHex(b[10]) + " " + Global.intToHex(b[11]) + "<br/>"; TextBox1 += "File last modification date: " + Global.intToHex(b[12]) + " " + Global.intToHex(b[13]) + "<br/>"; TextBox1 += "CRC: " + Global.intToHex(b[14]) + Global.intToHex(b[15]) + Global.intToHex(b[16]) + Global.intToHex(b[17]) + "<br/>"; TextBox1 += "Compessed size: " + Global.intToHex(b[18]) + Global.intToHex(b[19]) + Global.intToHex(b[20]) + Global.intToHex(b[21]) + "<br/>"; TextBox1 += "Uncompressed size: " + Global.intToHex(b[22]) + Global.intToHex(b[23]) + Global.intToHex(b[24]) + Global.intToHex(b[25]) + "<br/>"; TextBox1 += "File name length: " + Global.intToHex(b[26]) + Global.intToHex(b[27]) + "<br/>"; TextBox1 += "Extra field length: " + Global.intToHex(b[28]) + Global.intToHex(b[29]) + "<br/>"; TextBox1 += "Filename: "; for (int i = 0; i < b[26]; i++) TextBox1 += (char)b[30 + i]; TextBox1 += "<br/>"; return (TextBox1); }