Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2017-13861/liboffsetfinder64/img4.h
Views: 11784
//1// img4.h2// img4tool3//4// Created by tihmstar on 15.06.16.5// Copyright © 2016 tihmstar. All rights reserved.6//78#ifndef img4_h9#define img4_h1011#ifdef __cplusplus12extern "C" {13#endif1415#include <stdio.h>16//#include <plist/plist.h>17#define LEN_XTND 0x80 /* Indefinite or long form */18typedef unsigned char byte;1920#define putStr(s,l) printf("%.*s",(int)l,s)2122//TagClass23#define kASN1TagClassUniversal 024#define kASN1TagClassApplication 125#define kASN1TagClassContextSpecific 226#define kASN1TagClassPrivate 32728//primitive29#define kASN1Primitive 030#define kASN1Contructed 13132//tagNumber33#define kASN1TagEnd_of_Content 034#define kASN1TagBOOLEAN 135#define kASN1TagINTEGER 236#define kASN1TagBIT 337#define kASN1TagOCTET 438#define kASN1TagNULL 539#define kASN1TagOBJECT 640#define kASN1TagObject 741#define kASN1TagEXTERNAL 842#define kASN1TagREAL 943#define kASN1TagENUMERATED 10 //0x0A44#define kASN1TagEMBEDDED 11 //0x0B45#define kASN1TagUTF8String 12 //0x0C46#define kASN1TagRELATIVE_OID 13 //0x0D47#define kASN1TagReserved (14 | 15) //(0x0E | 0x0F)48#define kASN1TagSEQUENCE 16 //0x1049#define kASN1TagSET 17 //0x1150#define kASN1TagNumericString 18 //0x1251#define kASN1TagPrintableString 19 //0x1352#define kASN1TagT61String 20 //0x1453#define kASN1TagVideotexString 21 //0x1554#define kASN1TagIA5String 22 //0x1655#define kASN1TagUTCTime 23 //0x1756#define kASN1TagGeneralizedTime 24 //0x1857#define kASN1TagGraphicString 25 //0x1958#define kASN1TagVisibleString 26 //0x1A59#define kASN1TagGeneralString 27 //0x1B60#define kASN1TagUniversalString 28 //0x1C61#define kASN1TagCHARACTER 29 //0x1D62#define kASN1TagBMPString 30 //0x1E63#define kASN1TagPrivate (char)0xff6465typedef struct{66byte tagNumber : 5;67byte isConstructed : 1;68byte tagClass : 2;69}t_asn1Tag;7071typedef struct{72byte len : 7;73byte isLong : 1;74}t_asn1Length;7576typedef struct{77size_t dataLen;78size_t sizeBytes;79} t_asn1ElemLen;8081typedef struct{82byte num : 7;83byte more : 1;84}t_asn1PrivateTag;858687#ifndef __cplusplus88typedef enum{89false,90true91}bool;92#endif9394//asn195t_asn1ElemLen asn1Len(const char buf[4]);96char *ans1GetString(char *buf, char **outString, size_t *strlen);97int asn1ElementsInObject(const char *buf);98char *asn1ElementAtIndex(const char *buf, int index);99100101char *getValueForTagInSet(char *set, uint32_t tag);102103104//img4105void printIM4P(char *buf);106void printIM4R(char *buf);107void printIM4M(char *buf, bool printAll);108void printMANB(char *buf, bool printAll);109110int sequenceHasName(const char *buf, char *name);111int getSequenceName(const char *buf,char**name, size_t *nameLen);112size_t asn1GetPrivateTagnum(t_asn1Tag *tag, size_t *sizebytes);113int extractFileFromIM4P(char *buf, const char *dstFilename);114void printElemsInIMG4(char *buf, bool printAll, bool im4pOnly);115116char *getElementFromIMG4(char *buf, char* element);117int extractElementFromIMG4(char *buf, char* element, const char *dstFilename);118char *makeIMG4(char *im4p, char *im4m, char *im4r, size_t *size);119120char *getBNCHFromIM4M(const char* im4m, size_t *nonceSize);121char *getIM4PFromIMG4(char *buf);122char *getIM4MFromIMG4(char *buf);123124int replaceNameInIM4P(char *buf, const char *newName);125int verifyIM4MSignature(const char *buf);126//int verifyIMG4(char *buf, plist_t buildmanifest);127128//plist_t getBuildIdentityForIM4M(const char *buf, const plist_t buildmanifest);129//void printGeneralBuildIdentityInformation(plist_t buildidentity);130131char* extractPayloadFromIM4P(const char* buf, const char** compname, size_t *len);132133#ifdef __cplusplus134}135#endif136137#endif /* img4_h */138139140