├── .gitignore ├── API ├── Test │ └── Func_test.go ├── main.go ├── model │ └── aweme.go └── units │ ├── aweme.go │ ├── bridge.h │ ├── config.go │ ├── router.go │ └── utils.go ├── README.md ├── aweme-aes ├── CMakeLists.txt ├── hexstring.cpp ├── main.cpp ├── main.h ├── subs.cpp └── subs.h ├── ios_aweme_lib ├── awemeLib.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── awemeLib │ ├── awemeLib.h │ └── awemeLib.m └── ios_webserver ├── awemeDylib.h └── awemeDylib.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, build with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | ### Objective-C template 16 | # Xcode 17 | # 18 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 19 | 20 | ## Build generated 21 | build/ 22 | DerivedData/ 23 | 24 | ## Various settings 25 | *.pbxuser 26 | !default.pbxuser 27 | *.mode1v3 28 | !default.mode1v3 29 | *.mode2v3 30 | !default.mode2v3 31 | *.perspectivev3 32 | !default.perspectivev3 33 | xcuserdata/ 34 | 35 | ## Other 36 | *.moved-aside 37 | *.xccheckout 38 | *.xcscmblueprint 39 | 40 | ## Obj-C/Swift specific 41 | *.hmap 42 | *.ipa 43 | *.dSYM.zip 44 | *.dSYM 45 | 46 | # CocoaPods 47 | # 48 | # We recommend against adding the Pods directory to your .gitignore. However 49 | # you should judge for yourself, the pros and cons are mentioned at: 50 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 51 | # 52 | # Pods/ 53 | 54 | # Carthage 55 | # 56 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 57 | # Carthage/Checkouts 58 | 59 | Carthage/Build 60 | 61 | # fastlane 62 | # 63 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 64 | # screenshots whenever they are needed. 65 | # For more information about the recommended setup visit: 66 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 67 | 68 | fastlane/report.xml 69 | fastlane/Preview.html 70 | fastlane/screenshots/**/*.png 71 | fastlane/test_output 72 | 73 | # Code Injection 74 | # 75 | # After new code Injection tools there's a generated folder /iOSInjectionProject 76 | # https://github.com/johnno1962/injectionforxcode 77 | 78 | iOSInjectionProject/ 79 | ### C++ template 80 | # Prerequisites 81 | *.d 82 | 83 | # Compiled Object files 84 | *.slo 85 | *.lo 86 | *.o 87 | *.obj 88 | 89 | # Precompiled Headers 90 | *.gch 91 | *.pch 92 | 93 | # Compiled Dynamic libraries 94 | *.so 95 | *.dylib 96 | *.dll 97 | 98 | # Fortran module files 99 | *.mod 100 | *.smod 101 | 102 | # Compiled Static libraries 103 | *.lai 104 | *.la 105 | *.a 106 | *.lib 107 | 108 | # Executables 109 | *.exe 110 | *.out 111 | *.app 112 | 113 | /API/.idea/ 114 | /API/vendor/ 115 | /API/Gopkg.toml 116 | /API/Gopkg.lock 117 | /API/out/ 118 | /encryptDataWithTimeStamp/awemeLib.xcodeproj/xcuserdata/ 119 | /encryptDataWithTimeStamp/awemeLib.xcodeproj/project.xcworkspace/xcuserdata/ 120 | /ios_webserver/aweme/TargetApp_Headers/ 121 | /ios_webserver/aweme/TargetApp/ 122 | /ios_webserver/aweme/Aweme_Headers/ 123 | .idea/* -------------------------------------------------------------------------------- /API/Test/Func_test.go: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | import ( 4 | "testing" 5 | "net/url" 6 | "aweme-api/units" 7 | ) 8 | 9 | func TestJson2B64(t *testing.T) { 10 | cypherText := "5pe9vb%2F%2B9OnkwvP88Pi%2Fvae9v3sVDXQeIL%2Bxl729v%2B7o%2F%2FD06cLp9PD4v72nvayo%0D%0Arqmkrq2rqKWzpaikq66upJfg" 11 | cypherText, err := url.QueryUnescape(cypherText) 12 | if err!=nil{ 13 | t.Error(err.Error()) 14 | } 15 | units.AwemeJsonB64_decode(cypherText) 16 | plainText := units.AwemeJsonB64_decode(cypherText) 17 | println(plainText) 18 | cypherText = units.AwemeJsonB64_encode(plainText) 19 | println(cypherText) 20 | 21 | //if val != "hello" { 22 | // t.Error("Set Field") 23 | //} 24 | } -------------------------------------------------------------------------------- /API/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "aweme-api/units" 6 | ) 7 | 8 | func main() { 9 | r := gin.Default() 10 | units.R(r) 11 | // Listen and serve on 0.0.0.0:8080 12 | r.Run(":9999") 13 | } 14 | -------------------------------------------------------------------------------- /API/model/aweme.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type Json_masas struct { 4 | Mas string `json:"mas"` 5 | As string `json:"as"` 6 | Ts string `json:"ts"` 7 | } 8 | 9 | type Json_iid struct { 10 | MagicTag string `json:"magic_tag"` 11 | Fingerprint string `json:"fingerprint"` 12 | Header struct { 13 | SdkVersion int `json:"sdk_version"` 14 | Language string `json:"language"` 15 | UserAgent string `json:"user_agent"` 16 | AppVersion string `json:"app_version"` 17 | VendorID string `json:"vendor_id"` 18 | IsUpgradeUser bool `json:"is_upgrade_user"` 19 | Region string `json:"region"` 20 | Channel string `json:"channel"` 21 | MccMnc string `json:"mcc_mnc"` 22 | TzOffset int `json:"tz_offset"` 23 | AppRegion string `json:"app_region"` 24 | Resolution string `json:"resolution"` 25 | Aid string `json:"aid"` 26 | Os string `json:"os"` 27 | DeviceID string `json:"device_id"` 28 | Custom struct { 29 | AppRegion string `json:"app_region"` 30 | AppLanguage string `json:"app_language"` 31 | } `json:"custom"` 32 | Access string `json:"access"` 33 | Openudid string `json:"openudid"` 34 | Carrier string `json:"carrier"` 35 | InstallID string `json:"install_id"` 36 | Timezone int `json:"timezone"` 37 | IsJailbroken bool `json:"is_jailbroken"` 38 | DeviceModel string `json:"device_model"` 39 | OsVersion string `json:"os_version"` 40 | Mc string `json:"mc"` 41 | DisplayName string `json:"display_name"` 42 | Package string `json:"package"` 43 | TzName string `json:"tz_name"` 44 | AppLanguage string `json:"app_language"` 45 | Idfa string `json:"idfa"` 46 | } `json:"header"` 47 | } -------------------------------------------------------------------------------- /API/units/aweme.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | /* 4 | #cgo LDFLAGS: -ldl 5 | #include 6 | #include 7 | int test(char* lib_path){ 8 | char* func_name="test"; 9 | void* libc; 10 | int (*test_call)(); 11 | int rst; 12 | if(libc = dlopen(lib_path,RTLD_LAZY)) 13 | { 14 | test_call = dlsym(libc, func_name); 15 | rst = (*test_call)(6,2); 16 | dlclose(libc); 17 | } 18 | return rst; 19 | } 20 | 21 | char* testchar(char* lib_path, char* paramaJsonStr){ 22 | char* func_name="testchar"; 23 | void* libc; 24 | char* (*testchar)(); 25 | char* rst; 26 | if(libc = dlopen(lib_path,RTLD_LAZY)) 27 | { 28 | testchar = dlsym(libc, func_name); 29 | rst = (*testchar)(paramaJsonStr); 30 | dlclose(libc); 31 | } 32 | return rst; 33 | } 34 | 35 | char* encryptDataWithTimeStamp(char* lib_path, char* paramaJsonStr, int timeStamp, char *deviceIDStr, char *libPath){ 36 | char* func_name="encryptDataWithTimeStamp"; 37 | void* libc; 38 | char* (*encryptDataWithTimeStamp)(); 39 | char* rst; 40 | if(libc = dlopen(lib_path,RTLD_LAZY)) 41 | { 42 | encryptDataWithTimeStamp = dlsym(libc, func_name); 43 | rst = (*encryptDataWithTimeStamp)(paramaJsonStr, timeStamp, deviceIDStr, libPath); 44 | dlclose(libc); 45 | } 46 | return rst; 47 | } 48 | */ 49 | //import "C" 50 | 51 | //func EncryptDataWithTimeStamp(paramStr string, ts int, deviceIDStr string) model.Json_masas{ 52 | // var EXTENSION_DIR string = "./lib/" 53 | // var OIDB_API string = "libawemeLib.dylib" 54 | // libPathC := C.CString(EXTENSION_DIR+OIDB_API) 55 | // defer C.free(unsafe.Pointer(libPathC)) 56 | // cstr := C.CString(paramStr) 57 | //// cstr := C.CString(`{ 58 | //// "iid":"31498571605", 59 | //// "aid":"1128", 60 | //// "ts":"1524622784", 61 | //// "os_api":"18", 62 | //// "build_number":"17805", 63 | //// "channel":"App Store", 64 | //// "device_platform":"iphone", 65 | //// "app_version":"1.7.8", 66 | //// "app_name":"aweme", 67 | //// "vid":"612E0CAA-4C70-4E21-B6D7-8C386F862C6D", 68 | //// "openudid":"2222222222222222222222222222222222222222", 69 | //// "device_type":"iPhone7,2", 70 | //// "idfa":"5A8CD0BE-EF7E-45C1-9056-094CA9FB51CC", 71 | //// "device_id":"51737442652", 72 | //// "ac":"WIFI", 73 | //// "version_code":"1.7.8", 74 | //// "os_version":"9.3.3", 75 | //// "screen_width":"750" 76 | //// 77 | ////}`) 78 | // deviceID := C.CString(deviceIDStr) 79 | // libPath := C.CString("/lib/Awemex64_1.8.0.dylib") 80 | // defer C.free(unsafe.Pointer(cstr)) 81 | // defer C.free(unsafe.Pointer(deviceID)) 82 | // defer C.free(unsafe.Pointer(libPath)) 83 | // OCStr := C.encryptDataWithTimeStamp(libPathC, cstr, C.int(ts), deviceID, libPath) 84 | // //defer C.free(unsafe.Pointer(rst2)) 85 | // GOStr := C.GoString(OCStr) 86 | // 87 | // var Json_masas model.Json_masas 88 | // err := json.Unmarshal([]byte(GOStr), &Json_masas) 89 | // if err != nil{ 90 | // logs.Error("C function encryptDataWithTimeStamp return: ", GOStr) 91 | // panic(err.Error()) 92 | // } 93 | // return Json_masas 94 | // 95 | //} -------------------------------------------------------------------------------- /API/units/bridge.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int test(char* lib_path){ 7 | void *dl = dlopen(lib_path,RTLD_LAZY); //打开动态库 8 | if (dl == NULL) 9 | fprintf(stderr,"Error:failed to load libary.\n"); 10 | char *error = dlerror(); //检测错误 11 | if (error != NULL) 12 | { 13 | fprintf(stderr,"%s\n",error); 14 | //return -1; 15 | } 16 | int (*func)(int x, int y) = dlsym(dl,"test_sum"); // 获取函数地址 17 | error = dlerror(); //检测错误 18 | if (error != NULL) 19 | { 20 | fprintf(stderr,"%s\n",error); 21 | //return -1; 22 | } 23 | int rst = func(1, 2); 24 | dlclose(dl); //关闭动态库 25 | error = dlerror(); //检测错误 26 | if (error != NULL) 27 | { 28 | fprintf(stderr,"%s\n",error); 29 | //return -1; 30 | } 31 | return rst; 32 | } 33 | 34 | char* encode(char* lib_path, char* plain, int plainlength, char* key, int keylength){ 35 | void *dl = dlopen(lib_path,RTLD_LAZY); //打开动态库 36 | if (dl == NULL) 37 | fprintf(stderr,"Error:failed to load libary.\n"); 38 | char *error = dlerror(); //检测错误 39 | if (error != NULL) 40 | { 41 | fprintf(stderr,"%s\n",error); 42 | //return -1; 43 | } 44 | char* (*func)(char* plain, int plainlength, char* key, int keylength) = dlsym(dl,"Encode"); // 获取函数地址 45 | error = dlerror(); //检测错误 46 | if (error != NULL) 47 | { 48 | fprintf(stderr,"%s\n",error); 49 | //return -1; 50 | } 51 | char* rst = func(plain, plainlength, key, keylength); 52 | dlclose(dl); //关闭动态库 53 | error = dlerror(); //检测错误 54 | if (error != NULL) 55 | { 56 | fprintf(stderr,"%s\n",error); 57 | //return -1; 58 | } 59 | return rst; 60 | } -------------------------------------------------------------------------------- /API/units/config.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | const Json_IDD_Str = `{ 4 | "magic_tag": "ss_app_log", 5 | "fingerprint": "", 6 | "header": { 7 | "sdk_version": 101, 8 | "language": "zh", 9 | "user_agent": "Aweme 2.6.0 rv:17603 (iPhone; iPhone OS 9.3.3; zh_CN)", 10 | "app_version": "2.6.0", 11 | "vendor_id": "3f8464bc-8934-11e8-9a94-a6cf71070000", 12 | "is_upgrade_user": false, 13 | "region": "CN", 14 | "channel": "App Store", 15 | "mcc_mnc": "12345", 16 | "tz_offset": 28800, 17 | "app_region": "CN", 18 | "resolution": "750*1334", 19 | "aid": "1128", 20 | "os": "iOS", 21 | "device_id": "", 22 | "custom": { 23 | "app_region": "CN", 24 | "app_language": "zh" 25 | }, 26 | "access": "WIFI", 27 | "openudid": "2222222222232222222222222222222222222223", 28 | "carrier": "中国联通", 29 | "install_id": "", 30 | "timezone": 8, 31 | "is_jailbroken": false, 32 | "device_model": "iPhone 6", 33 | "os_version": "9.3.3", 34 | "mc": "00:00:00:00:00:00", 35 | "display_name": "抖音短视频", 36 | "package": "aweme", 37 | "tz_name": "Asia\/Shanghai", 38 | "app_language": "zh", 39 | "idfa": "DFCF4ABE-ECEB-4FCC-87D6-710cb1C20000" 40 | } 41 | }` 42 | 43 | const Json_IDD_Str_38 = `{ 44 | "magic_tag": "ss_app_log", 45 | "fingerprint": "", 46 | "header": { 47 | "sdk_version": 101, 48 | "language": "zh", 49 | "user_agent": "Aweme 3.8.0 rv:38006 (iPhone; iPhone OS 9.3.3; zh_CN)", 50 | "app_version": "3.8.0", 51 | "vendor_id": "3f8464bc-8934-11e8-9a94-a6cf71070000", 52 | "is_upgrade_user": false, 53 | "region": "CN", 54 | "channel": "App Store", 55 | "mcc_mnc": "12345", 56 | "tz_offset": 28800, 57 | "app_region": "CN", 58 | "resolution": "750*1334", 59 | "aid": "1128", 60 | "os": "iOS", 61 | "device_id": "", 62 | "custom": { 63 | "app_region": "CN", 64 | "app_language": "zh" 65 | }, 66 | "access": "WIFI", 67 | "openudid": "2222222222232222222222222222222222222223", 68 | "carrier": "中国联通", 69 | "install_id": "", 70 | "timezone": 8, 71 | "is_jailbroken": false, 72 | "device_model": "iPhone 6", 73 | "os_version": "9.3.3", 74 | "mc": "00:00:00:00:00:00", 75 | "display_name": "抖音短视频", 76 | "package": "aweme", 77 | "tz_name": "Asia\/Shanghai", 78 | "app_language": "zh", 79 | "idfa": "DFCF4ABE-ECEB-4FCC-87D6-710cb1C20000" 80 | } 81 | }` 82 | -------------------------------------------------------------------------------- /API/units/router.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "aweme-api/model" 5 | "crypto/tls" 6 | "encoding/base64" 7 | "encoding/json" 8 | "fmt" 9 | "github.com/gin-gonic/gin" 10 | "io/ioutil" 11 | "net/http" 12 | "strings" 13 | ) 14 | 15 | func R(r *gin.Engine) { 16 | r.POST("/encryptDataWithTimeStamp_tran", r_encryptDataWithTimeStamp_tran) 17 | r.POST("/genHardInfo", r_genHardInfo) 18 | r.POST("/deviceReg", r_deviceReg) 19 | r.POST("/mixStringWithString", r_mixStringWithString) 20 | r.POST("/awemeJsonB64_decode_pri", r_awemeJsonB64_decode) 21 | r.POST("/awemeJsonB64_encode", r_awemeJsonB64_encode) 22 | } 23 | 24 | 25 | 26 | func r_encryptDataWithTimeStamp_tran(c *gin.Context) { 27 | loginUrl := fmt.Sprintf("http://192.168.31.206:8080/encryptDataWithTimeStamp") 28 | //proxy := func(_ *http.Request) (*url.URL, error) { 29 | // return url.Parse("http://127.0.0.1:8080") 30 | //} 31 | transport := &http.Transport{ 32 | //Proxy: proxy, 33 | TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, 34 | } 35 | client := &http.Client{Transport: transport} 36 | //client := &http.Client{} 37 | paramaJson := c.PostForm("paramaJson") 38 | timeStamp := c.PostForm("timeStamp") 39 | 40 | postData := fmt.Sprintf("paramaJson=%s&timeStamp=%s", paramaJson, timeStamp) 41 | req, err := http.NewRequest("POST", loginUrl, strings.NewReader(postData)) 42 | 43 | //req, err = http.NewRequest("POST", loginUrl, strings.NewReader(string("123123"))) 44 | if err != nil { 45 | panic(err.Error()) 46 | } 47 | //req.Header.Set("Content-Type", "application/octet-stream;tt-data=a") 48 | resp, err := client.Do(req) 49 | defer resp.Body.Close() 50 | body, err := ioutil.ReadAll(resp.Body) 51 | if err != nil { 52 | panic(err) 53 | } 54 | c.String(http.StatusOK, string(body)) 55 | } 56 | 57 | func r_genHardInfo(c *gin.Context) { 58 | var jIID model.Json_iid 59 | var carrier string 60 | sp := c.PostForm("sp") 61 | switch sp{ 62 | case "0": 63 | carrier = GBK2Utf8("中国联通") 64 | break 65 | case "1": 66 | carrier = GBK2Utf8("中国移动") 67 | break 68 | default: 69 | c.JSON(http.StatusBadRequest, nil) 70 | return 71 | } 72 | json.Unmarshal([]byte(Json_IDD_Str_38), &jIID) 73 | //jIID.Header.Carrier = base64.StdEncoding.EncodeToString([]byte(GBK2Utf8("中国联通"))) 74 | jIID.Header.Carrier = base64.StdEncoding.EncodeToString([]byte(carrier)) 75 | jIID.Header.DisplayName = base64.StdEncoding.EncodeToString([]byte(jIID.Header.DisplayName)) 76 | jIID.Header.Idfa = GenIDFA() 77 | jIID.Header.VendorID = GenUUID() 78 | jIID.Header.Openudid = GenOpenUDID() 79 | //jStr, err := json.Marshal(jIID) 80 | //if err != nil { 81 | // panic(err.Error()) 82 | //} 83 | c.JSON(http.StatusOK, jIID) 84 | } 85 | 86 | func r_mixStringWithString(c *gin.Context) { 87 | plainStr := c.PostForm("plainStr") 88 | c.String(http.StatusOK, MixStringWithString(plainStr)) 89 | } 90 | 91 | func r_deviceReg(c *gin.Context) { 92 | //loginUrl := fmt.Sprintf("https://log.snssdk.com/service/2/device_register/?") 93 | hardInfo := c.PostForm("hardInfo") 94 | var jIID model.Json_iid 95 | json.Unmarshal([]byte(hardInfo), &jIID) 96 | displayName, err := base64.StdEncoding.DecodeString(jIID.Header.DisplayName) 97 | if err != nil { 98 | panic(err) 99 | } 100 | jIID.Header.DisplayName = string(displayName) 101 | carrier, err := base64.StdEncoding.DecodeString(jIID.Header.Carrier) 102 | if err != nil { 103 | panic(err) 104 | } 105 | jIID.Header.Carrier = string(carrier) 106 | c.String(http.StatusOK, base64.StdEncoding.EncodeToString(Serialize(jIID))) 107 | } 108 | 109 | func r_awemeJsonB64_decode(c *gin.Context) { 110 | cypherText := c.PostForm("cypherText") 111 | c.String(http.StatusOK, AwemeJsonB64_decode(cypherText)) 112 | } 113 | 114 | func r_awemeJsonB64_encode(c *gin.Context) { 115 | plainText := c.PostForm("plainText") 116 | c.String(http.StatusOK, AwemeJsonB64_encode(plainText)) 117 | } 118 | -------------------------------------------------------------------------------- /API/units/utils.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | /* 4 | #cgo CFLAGS: -I/Users/SomePath/dev/C++/aweme_aes/ 5 | #cgo LDFLAGS: -lstdc++ 6 | //#cgo LDFLAGS: -L/Users/SomePath/dev/C++/aweme_aes/cmake-build-debug -llibaweme_aes 7 | //#include "main.h" 8 | #cgo LDFLAGS: -ldl 9 | #include "bridge.h" 10 | */ 11 | import "C" 12 | import ( 13 | "encoding/hex" 14 | "unsafe" 15 | "bytes" 16 | "compress/gzip" 17 | "io" 18 | "encoding/json" 19 | "fmt" 20 | "github.com/axgle/mahonia" 21 | "crypto/md5" 22 | "math/rand" 23 | "time" 24 | "github.com/satori/go.uuid" 25 | "aweme-api/model" 26 | "encoding/base64" 27 | ) 28 | 29 | //var EXTENSION_DIR string = "/Users/SomePath/dev/C++/aweme_aes/cmake-build-debug/" 30 | var EXTENSION_DIR string = "/root/dev/aweme_aes/" 31 | var OIDB_API string = "libaweme_aes.so" 32 | //来自抖音函数 mixStringWithString 33 | func MixStringWithString(plainStr string) string { 34 | var rst string = "" 35 | var cryptStr string = "" 36 | for _, v := range plainStr { 37 | char := byte(v) ^ 5 38 | cryptStr += hex.EncodeToString([]byte{char}) 39 | } 40 | rst = cryptStr 41 | return rst 42 | } 43 | 44 | func IIDEncrypt(plainStr []byte) []byte { 45 | CplainStr := C.CString(string(plainStr)) 46 | defer C.free(unsafe.Pointer(CplainStr)) 47 | plainlength := len(plainStr) 48 | libPathC := C.CString(EXTENSION_DIR + OIDB_API) 49 | defer C.free(unsafe.Pointer(libPathC)) 50 | encryptedLength := plainlength + 4 + (16 - plainlength%16) 51 | CKeyStr := C.CString("!*ss!_defaul%t54K&EY") 52 | defer C.free(unsafe.Pointer(CKeyStr)) 53 | CEncryptedStr := C.encode(libPathC, CplainStr, C.int(encryptedLength), CKeyStr, C.int(20)) 54 | defer C.free(unsafe.Pointer(CEncryptedStr)) 55 | encryptedStr := C.GoBytes(unsafe.Pointer(CEncryptedStr), C.int(encryptedLength)) 56 | //encryptedHexStr := hex.EncodeToString(encryptedStr) 57 | return encryptedStr 58 | } 59 | 60 | func Test(plainStr string) int { 61 | libPathC := C.CString(EXTENSION_DIR + OIDB_API) 62 | defer C.free(unsafe.Pointer(libPathC)) 63 | return int(C.test(libPathC)) 64 | //C.test1() 65 | } 66 | 67 | func GUnzipData(data []byte) (resData []byte, err error) { 68 | b := bytes.NewBuffer(data) 69 | 70 | var r io.Reader 71 | r, err = gzip.NewReader(b) 72 | if err != nil { 73 | return 74 | } 75 | 76 | var resB bytes.Buffer 77 | _, err = resB.ReadFrom(r) 78 | if err != nil { 79 | return 80 | } 81 | 82 | resData = resB.Bytes() 83 | 84 | return 85 | } 86 | 87 | func GZipData(data []byte) (compressedData []byte, err error) { 88 | var b bytes.Buffer 89 | gz := gzip.NewWriter(&b) 90 | 91 | _, err = gz.Write(data) 92 | if err != nil { 93 | return 94 | } 95 | 96 | if err = gz.Flush(); err != nil { 97 | return 98 | } 99 | 100 | if err = gz.Close(); err != nil { 101 | return 102 | } 103 | 104 | compressedData = b.Bytes() 105 | 106 | return 107 | } 108 | 109 | func JsonStr2Getparam(jsonStr []byte) string { 110 | var getParamStr string 111 | var data map[string][]map[string]interface{} 112 | err := json.Unmarshal(jsonStr, &data) 113 | if err != nil { 114 | panic(err.Error()) 115 | } 116 | for k, v := range data { 117 | getParamStr += fmt.Sprintf("%s=%s&", k, v) 118 | } 119 | return getParamStr 120 | } 121 | 122 | func Utf82GBK(utf8Str string) string { 123 | enc := mahonia.NewEncoder("GBK") 124 | output := enc.ConvertString(utf8Str) 125 | return output 126 | } 127 | 128 | func GBK2Utf8(gbkStr string) string { 129 | enc := mahonia.NewDecoder("GBK") 130 | output := enc.ConvertString(gbkStr) 131 | return output 132 | } 133 | 134 | // 生成32位MD5 135 | func MD5(text string) string { 136 | ctx := md5.New() 137 | ctx.Write([]byte(text)) 138 | return hex.EncodeToString(ctx.Sum(nil)) 139 | } 140 | 141 | // return len=8 salt 142 | func GetRandomSalt() string { 143 | return GetRandomString(8) 144 | } 145 | 146 | //生成随机字符串 147 | func GetRandomString(length int) string { 148 | str := "0123456789abcdef" 149 | bytes := []byte(str) 150 | result := []byte{} 151 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 152 | for i := 0; i < length; i++ { 153 | result = append(result, bytes[r.Intn(len(bytes))]) 154 | } 155 | return string(result) 156 | } 157 | 158 | func GenUUID() string { 159 | u4 := uuid.NewV5(uuid.NewV4(), "aweme") 160 | return u4.String() 161 | } 162 | 163 | func GenOpenUDID() string { 164 | //return fmt.Sprintf("%s%s", MD5(globallyUniqueString), GetRandomString(8)) 165 | return fmt.Sprintf("%s%s%s", "222ae7d", GetRandomString(25), "11222222") 166 | } 167 | 168 | func GenIDFA() string { 169 | //return fmt.Sprintf("%s%s", MD5(globallyUniqueString), GetRandomString(8)) 170 | return fmt.Sprintf("%s%s", "DFCF4ABE-ECEB-4FCC-87D6-", GetRandomString(12)) 171 | } 172 | 173 | func Serialize(paramStr model.Json_iid) []byte { 174 | iidStr, err := json.Marshal(¶mStr) 175 | if err != nil{ 176 | panic(err.Error()) 177 | } 178 | gzipedIIDStr, err := GZipData(iidStr) 179 | if err != nil { 180 | panic(err.Error()) 181 | } 182 | encryptedIIDStr := IIDEncrypt(gzipedIIDStr) 183 | return encryptedIIDStr 184 | } 185 | 186 | func AwemeJsonB64_encode(jsonStr string) (string){ 187 | jsonBytes := []byte(jsonStr) 188 | var cypherBytes []byte 189 | for _, v :=range jsonBytes{ 190 | cypherBytes = append(cypherBytes, v ^ 0x9d) 191 | } 192 | return string(base64.StdEncoding.EncodeToString(cypherBytes)) 193 | } 194 | 195 | func AwemeJsonB64_decode(b64Str string) (string){ 196 | cypherBytes, err := base64.StdEncoding.DecodeString(b64Str) 197 | if err != nil{ 198 | panic(err) 199 | } 200 | 201 | var newBytes []byte 202 | for _, v :=range cypherBytes{ 203 | newBytes = append(newBytes, v ^ 0x9d) 204 | } 205 | return string(newBytes) 206 | } 207 | //const ( 208 | // base64Table = "123QRSTUabcdVWXYZHijKLAWDCABDstEFGuvwxyzGHIJklmnopqr234560178912" 209 | //) 210 | // 211 | //var coder = base64.NewEncoding(base64Table) 212 | // 213 | //func base64Encode(src string) string { 214 | // return coder.EncodeToString([]byte(src)) 215 | //} 216 | // 217 | //func base64Decode(src string) ([]byte, error) { 218 | // return coder.DecodeString(src) 219 | //} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aweme-algorithm 2 | iOS版抖音协议中的加解密算法实现
3 | 前两年的工作中涉及到抖音协议的分析部分,分析了两个跟加密有关的接口,项目结束了,现拿出来与大家分享
4 | 因为项目结束,最新版本是否有改动不清楚了,当时测试可用的抖音版本:IOS 1.7.8-3.8.0
5 |
6 | 1.设备信息生成方案:
7 | 设备信息中有几个重点:
8 | (1) carrier、display_name字段:这个字段不是utf-8编码,是GBK编码,要做编码转换
9 | (2) Idfa、VendorID字段:标准UUID算法生成即可
10 | (3) Openudid:这个地方有点头疼,根据所有公开资料,包括抖音自己的代码逆向,都可以看出来实际上是随机生成的,但是随机的没法通过服务器校验,最后使用了真Openudid替换掉中间16字节的方法,服务器通过率在60%左右
11 |
12 |
13 | 2./service/2/device_register/接口加密算法:
14 | device_register接口中post包体是加密的,算法实际上是AES,但是不知道为何标准AES实现跑出来的结果不对,不过没关系,直接从IDA伪代码里扒出来即可,中间有5处要修复xray的寄存器解析错误。 15 |
16 |
17 | 3.MAS、AS、TS算法:
18 | 这部分最头疼,花了很多时间一直想脱机跑,首先伪代码难以修复,因为有两个问题没法解决,1.ios的native API调用(例如线程锁) 2.类的上下文没法初始化,然后Unicorn模拟汇编代码也是一样的问题,没法解决native API调用,最后采用了Hook抖音app的encryptDataWithTimeStamp:parameters函数,然后在Hook代码中阻塞线程,跑个webserver,让抖音app自己初始化类并且准备上下文,然后webserver负责处理加解密,并且返回MAS AS TS
19 |
20 | 源码结构简单说明:
21 | 1.API是所有加解密的接口,负责给其他需要抖音加解密的业务提供加解密服务,用golang+C混编实现,device_reg的加解密是C写的库文件,通过调用桥调用so,下个部分会说明。
22 | 2.aweme-aes是device_reg的加解密实现,纯C代码,编译出来是so库,供上面上面的API调用。
23 | 3.ios_aweme_lib的功能是golang->抖音app2lib的桥接,调用流程是API ->ios_aweme_lib ->抖音lib,因为早期的方案是把抖音app2lib,然后通过golang写的webserver(交叉编译到ios)调用这个桥接库,然后调用抖音app,实现encryptDataWithTimeStamp,后来直接采用阻塞app跑webserver的方案后废弃了。
24 | 4.ios_webserver,这是Hook抖音app并阻塞encryptDataWithTimeStamp然后跑webserver的实现,框架是monkeydev,框架代码没上传,github上有搜monkeydev就行。
25 |
26 | 授权协议:只允许研究、学习目的的分享、使用、修改,不允许任何商业用途。转载请注明出处,感谢。
-------------------------------------------------------------------------------- /aweme-aes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | project(aweme_aes) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | SET (aweme_aes_src main.cpp subs.cpp subs.h hexstring.cpp main.h) 6 | #SET (aweme_aes_src main.cpp main.h) 7 | #add_executable( 8 | # aweme_aes main.cpp subs.cpp subs.h 9 | # hexstring.cpp) 10 | 11 | include_directories(/Applications/IDA\ Pro\ 7.0/ida.app/Contents/MacOS/plugins/) 12 | 13 | ADD_LIBRARY (aweme_aes SHARED ${aweme_aes_src}) 14 | 15 | #ADD_LIBRARY (aweme_aes STATIC ${aweme_aes} main.h) 16 | 17 | #SET_TARGET_PROPERTIES (aweme_aes PROPERTIES OUTPUT_NAME "aweme_aes") -------------------------------------------------------------------------------- /aweme-aes/hexstring.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Brian.W on 2018/3/28. 3 | // 4 | #include "subs.h"; 5 | #include "string"; 6 | 7 | using namespace std; 8 | string strToHex(string input) 9 | { 10 | static const char* const lut = "0123456789ABCDEF"; 11 | size_t len = input.length(); 12 | 13 | std::string output; 14 | output.reserve(2 * len); 15 | for (size_t i = 0; i < len; ++i) 16 | { 17 | const unsigned char c = input[i]; 18 | output.push_back(lut[c >> 4]); 19 | output.push_back(lut[c & 15]); 20 | } 21 | return output; 22 | } 23 | 24 | string hexToStr(string hexStr) 25 | { 26 | int len = hexStr.length(); 27 | std::string newString; 28 | for(int i=0; i< len; i+=2) 29 | { 30 | string byte = hexStr.substr(i,2); 31 | char chr = (char) (int)strtol(byte.c_str(), NULL, 16); 32 | newString.push_back(chr); 33 | } 34 | return newString; 35 | } 36 | 37 | 38 | string charsToHex(unsigned char* input, int length) 39 | { 40 | static const char* const lut = "0123456789ABCDEF"; 41 | size_t len = length; 42 | 43 | std::string output; 44 | output.reserve(2 * len); 45 | for (size_t i = 0; i < len; ++i) 46 | { 47 | const unsigned char c = input[i]; 48 | output.push_back(lut[c >> 4]); 49 | output.push_back(lut[c & 15]); 50 | } 51 | return output; 52 | } -------------------------------------------------------------------------------- /aweme-aes/main.cpp: -------------------------------------------------------------------------------- 1 | // aweme_aes.cpp: 定义控制台应用程序的入口点。 2 | // 3 | #include 4 | #include "subs.h" 5 | //#include 6 | #include 7 | //#include 8 | //#include 9 | #include "main.h" 10 | 11 | using namespace std; 12 | 13 | //string Encode(string hexplain, string key) 14 | //{ 15 | // string plain = hexToStr(hexplain); 16 | // char *xkey; 17 | // char *xplain; 18 | // int keylength = key.length(); 19 | // int plainlength = plain.length(); 20 | // xkey = (char*) malloc(keylength); 21 | // xplain = (char*) malloc(plainlength); 22 | // memcpy(xkey, key.data(), keylength); 23 | // memcpy(xplain, plain.data(), plainlength); 24 | // unsigned char *out = (unsigned char*) malloc(plainlength + 100); 25 | // aweme_aes((__int64)xplain, plainlength, (__int64)xkey, keylength, (__int64)out); 26 | // free(xkey); 27 | // free(xplain); 28 | // xkey = NULL; 29 | // xplain = NULL; 30 | // int cryptedStr_length = plainlength + 4 + (16 - plainlength%16); 31 | // std::string hexStr = charsToHex(out, cryptedStr_length); 32 | // free(out); 33 | // out = NULL; 34 | // return hexStr; 35 | //} 36 | 37 | char* Encode(char* plain, int plainlength, char* key, int keylength) 38 | { 39 | //string plain = hexToStr(hexplain); 40 | char *xkey; 41 | char *xplain; 42 | //int keylength = key.length(); 43 | //int plainlength = plain.length(); 44 | xkey = (char*) malloc(keylength); 45 | xplain = (char*) malloc(plainlength); 46 | memcpy(xkey, key, keylength); 47 | memcpy(xplain, plain, plainlength); 48 | unsigned char *out = (unsigned char*) malloc(plainlength + 100); 49 | aweme_aes((__int64)xplain, plainlength, (__int64)xkey, keylength, (__int64)out); 50 | free(xkey); 51 | free(xplain); 52 | xkey = NULL; 53 | xplain = NULL; 54 | // int cryptedStr_length = plainlength + 4 + (16 - plainlength%16); 55 | // std::string hexStr = charsToHex(out, cryptedStr_length); 56 | // free(out); 57 | //out = NULL; 58 | return (char*)out; 59 | } 60 | 61 | int main(){ 62 | printf("123"); 63 | } 64 | 65 | void func_test(){ 66 | printf("test"); 67 | } 68 | 69 | int test_sum(int x, int y){ 70 | return x+y; 71 | } -------------------------------------------------------------------------------- /aweme-aes/main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Brian.W on 2018/3/28. 3 | // 4 | 5 | #ifndef AWEME_AES_MAIN_H 6 | #define AWEME_AES_MAIN_H 7 | 8 | #endif //AWEME_AES_MAIN_H 9 | 10 | #include "string.h" 11 | extern "C" void func_test(); 12 | extern "C" int test_sum(int x, int y); 13 | extern "C" char* Encode(char* plain, int plainlength, char* key, int keylength); -------------------------------------------------------------------------------- /aweme-aes/subs.cpp: -------------------------------------------------------------------------------- 1 | #include "subs.h" 2 | 3 | 4 | 5 | 6 | uint32 bswap32(uint32 x) 7 | { 8 | return ((x << 24) & 0xff000000) | 9 | ((x << 8) & 0x00ff0000) | 10 | ((x >> 8) & 0x0000ff00) | 11 | ((x >> 24) & 0x000000ff); 12 | } 13 | unsigned char InvSbox[256] = { // inverse s-box 14 | 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 15 | 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 16 | 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 17 | 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 18 | 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 19 | 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 20 | 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 21 | 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 22 | 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 23 | 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 24 | 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 25 | 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 26 | 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 27 | 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 28 | 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 29 | 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; 30 | 31 | unsigned char Sbox[256] = { // forward s-box 32 | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 33 | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 34 | 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 35 | 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 36 | 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 37 | 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 38 | 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 39 | 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 40 | 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 41 | 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 42 | 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 43 | 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 44 | 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 45 | 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 46 | 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 47 | 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; 48 | 49 | __int64 aweme_aes(__int64 plainStr, __int64 plainStr_length, __int64 key, __int64 key_length, __int64 strOut) 50 | { 51 | return sub_1005D099C((const void *)plainStr, plainStr_length, (void *)key, key_length, (_BYTE *)strOut, 2); 52 | } 53 | 54 | signed __int64 sub_1005D099C(const void *plainStr, signed int plainStr_length, void *keyStr, signed int keyStr_Length, _BYTE *strOut, char value_2) 55 | { 56 | char v6; // w21 57 | _BYTE *strOut2; // x19 58 | signed int v8; // w20 59 | const void *v9; // x22 60 | signed __int64 result; // x0 61 | int v11; // w8 62 | unsigned int v12; // w8 63 | int v13; // w9 64 | int v14; // w8 65 | unsigned int v15; // w24 66 | int v16; // w25 67 | _BYTE *v17; // x23 68 | signed __int64 v18; // x8 69 | signed __int64 v19; // x8 70 | int v20; // w10 71 | int w11; // w11 72 | int w12; // w12 73 | int w14; // w14 74 | unsigned int *v24; // x13 75 | unsigned int v25; // w16 76 | unsigned int *v26; // [xsp+8h] [xbp-58h] 77 | int v27; // [xsp+Ch] [xbp-54h] 78 | int v28; // [xsp+10h] [xbp-50h] 79 | int v29; // [xsp+14h] [xbp-4Ch] 80 | 81 | v26 = (unsigned int*) malloc(1000); 82 | v6 = value_2; 83 | strOut2 = strOut; 84 | v8 = plainStr_length; 85 | v9 = plainStr; 86 | result = 0xFFFFFFFFLL; 87 | if (keyStr_Length >= 1 && keyStr && plainStr_length >= 1 && strOut) 88 | { 89 | sub_1005D0B50(keyStr, keyStr_Length, (unsigned int *)v26); 90 | //sub_1005D0B50(a3, a4, (unsigned int *)&v26); 91 | v11 = v8 + 15; 92 | if (v8 >= 0) 93 | v11 = v8; 94 | v12 = v8 - (v11 & 0xFFFFFFF0); 95 | v13 = 16 - v12; 96 | v14 = 31 - v12; 97 | if (v13 >= 0) 98 | v14 = v13; 99 | v15 = v13 - (v14 & 0xFFFFFFF0); 100 | v16 = v8 + v15 + 4; 101 | v17 = strOut2 + 4; 102 | memmove(strOut2 + 4, v9, v8); 103 | *strOut2 = 116; 104 | strOut2[1] = 99; 105 | strOut2[2] = v6; 106 | strOut2[3] = v15; 107 | if (v16 >= 5) //plainStr_length 108 | { 109 | v18 = (unsigned int)v16 - 4LL; 110 | do 111 | { 112 | *v17 = Sbox[(unsigned __int8)*v17]; 113 | ++v17; 114 | --v18; 115 | } while (v18); 116 | } 117 | if ((signed int)(v15 + v8) >= 16) 118 | { 119 | v19 = 0LL; 120 | // v20 = v26; //0x25 121 | // 122 | // w11 = (int)((&v26)[1]); 123 | // w12 = (int)((&v26)[2]); 124 | // w14 = (int)((&v26)[3]); 125 | v20 = *v26; //0x25 126 | //int * tmp1 = (int*)v20; 127 | w11 = v26[1]; 128 | // int * tmp2 = (int*)w11; 129 | w12 = v26[2]; 130 | //int * tmp3 = (int*)w12; 131 | w14 = v26[3]; 132 | //int * tmp4 = (int*)w14; 133 | v24 = (unsigned int *)(strOut2 + 16); 134 | do 135 | { 136 | v25 = *(v24 - 2); 137 | *(v24 - 3) = bswap32(bswap32(*(v24 - 3)) ^ v20); 138 | *(v24 - 2) = bswap32(w11 ^ __ROR4__(bswap32(v25), 24)); 139 | *(v24 - 1) = bswap32(w12 ^ __ROR4__(bswap32(*(v24 - 1)), 16)); 140 | *v24 = bswap32(w14 ^ __ROR4__(bswap32(*v24), 8)); 141 | v24 += 4; 142 | ++v19; 143 | } while (v19 < (v15 + v8) >> 4); 144 | } 145 | result = 0LL; 146 | } 147 | free(v26); 148 | v26 = NULL; 149 | return result; 150 | } 151 | 152 | void * sub_1005D0B50(void *keyStr, signed int keyStr_length, unsigned int *out) 153 | { 154 | unsigned int *out2; // x19 155 | signed int keyStr_length2; // w20 156 | signed int v5; // w21 157 | void *result; // x0 158 | __int64 v7; // x8 159 | bool v8; // nf 160 | unsigned __int8 v9; // vf 161 | __int64 v10; // x8 162 | unsigned int v11; // w9 163 | unsigned int v12; // w9 164 | 165 | out2 = out; 166 | keyStr_length2 = keyStr_length; 167 | if (keyStr_length >= 16) 168 | v5 = 16; 169 | else 170 | v5 = keyStr_length; 171 | result = memcpy(out, keyStr, v5); 172 | if (keyStr_length2 <= 15) 173 | { 174 | v7 = v5 + 1; 175 | do 176 | { 177 | *((_BYTE *)out2 + v7 - 1) = InvSbox[*((unsigned __int8 *)out2 + v7 - 2)]; 178 | v9 = __OFSUB__(v7, 16LL); 179 | v8 = v7++ - 16 < 0; 180 | } while (v8 ^ v9); 181 | } 182 | v10 = 0LL; 183 | do 184 | { 185 | *((_BYTE *)out2 + v10) = Sbox[*((unsigned __int8 *)out2 + v10)]; 186 | ++v10; 187 | } while (v10 != 16); 188 | v11 = out2[1]; 189 | *out2 = bswap32(*out2); //w10 190 | out2[1] = bswap32(v11); //w11 191 | v12 = out2[3]; 192 | out2[2] = bswap32(out2[2]); //w12 193 | out2[3] = bswap32(v12); //w14 194 | //printf(""); 195 | return result; 196 | } 197 | 198 | -------------------------------------------------------------------------------- /aweme-aes/subs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "defs.h" 3 | #include // pulls in declaration of malloc, free 4 | #include // pulls in declaration for strlen. 5 | #include // pulls in declaration for strlen. 6 | 7 | using namespace std; 8 | __int64 aweme_aes(__int64 plainStr, __int64 plainStr_length, __int64 key, __int64 key_length, __int64 strOut); 9 | void *sub_1005D0B50(void *keyStr, signed int keyStr_length, unsigned int *out); 10 | signed __int64 sub_1005D099C(const void *a1, signed int a2, void *keyStr, signed int keyStr_Length, _BYTE *strOut, char value_2); 11 | string hexToStr(string hexStr); 12 | string strToHex(string input); 13 | string charsToHex(unsigned char* input, int length); 14 | //extern string Encode(string hexplain, string key); -------------------------------------------------------------------------------- /ios_aweme_lib/awemeLib.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5C99A60B20A2DD090072FF66 /* awemeLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C99A60A20A2DD090072FF66 /* awemeLib.h */; }; 11 | 5C99A60D20A2DD090072FF66 /* awemeLib.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C99A60C20A2DD090072FF66 /* awemeLib.m */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXFileReference section */ 15 | 5C99A60720A2DD090072FF66 /* libawemeLib.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libawemeLib.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 16 | 5C99A60A20A2DD090072FF66 /* awemeLib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = awemeLib.h; sourceTree = ""; }; 17 | 5C99A60C20A2DD090072FF66 /* awemeLib.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = awemeLib.m; sourceTree = ""; }; 18 | /* End PBXFileReference section */ 19 | 20 | /* Begin PBXFrameworksBuildPhase section */ 21 | 5C99A60420A2DD090072FF66 /* Frameworks */ = { 22 | isa = PBXFrameworksBuildPhase; 23 | buildActionMask = 2147483647; 24 | files = ( 25 | ); 26 | runOnlyForDeploymentPostprocessing = 0; 27 | }; 28 | /* End PBXFrameworksBuildPhase section */ 29 | 30 | /* Begin PBXGroup section */ 31 | 5C99A5FE20A2DD080072FF66 = { 32 | isa = PBXGroup; 33 | children = ( 34 | 5C99A60920A2DD090072FF66 /* awemeLib */, 35 | 5C99A60820A2DD090072FF66 /* Products */, 36 | ); 37 | sourceTree = ""; 38 | }; 39 | 5C99A60820A2DD090072FF66 /* Products */ = { 40 | isa = PBXGroup; 41 | children = ( 42 | 5C99A60720A2DD090072FF66 /* libawemeLib.dylib */, 43 | ); 44 | name = Products; 45 | sourceTree = ""; 46 | }; 47 | 5C99A60920A2DD090072FF66 /* awemeLib */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | 5C99A60A20A2DD090072FF66 /* awemeLib.h */, 51 | 5C99A60C20A2DD090072FF66 /* awemeLib.m */, 52 | ); 53 | path = awemeLib; 54 | sourceTree = ""; 55 | }; 56 | /* End PBXGroup section */ 57 | 58 | /* Begin PBXHeadersBuildPhase section */ 59 | 5C99A60520A2DD090072FF66 /* Headers */ = { 60 | isa = PBXHeadersBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 5C99A60B20A2DD090072FF66 /* awemeLib.h in Headers */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXHeadersBuildPhase section */ 68 | 69 | /* Begin PBXNativeTarget section */ 70 | 5C99A60620A2DD090072FF66 /* awemeLib */ = { 71 | isa = PBXNativeTarget; 72 | buildConfigurationList = 5C99A61020A2DD090072FF66 /* Build configuration list for PBXNativeTarget "awemeLib" */; 73 | buildPhases = ( 74 | 5C99A60320A2DD090072FF66 /* Sources */, 75 | 5C99A60420A2DD090072FF66 /* Frameworks */, 76 | 5C99A60520A2DD090072FF66 /* Headers */, 77 | ); 78 | buildRules = ( 79 | ); 80 | dependencies = ( 81 | ); 82 | name = awemeLib; 83 | productName = awemeLib; 84 | productReference = 5C99A60720A2DD090072FF66 /* libawemeLib.dylib */; 85 | productType = "com.apple.product-type.library.dynamic"; 86 | }; 87 | /* End PBXNativeTarget section */ 88 | 89 | /* Begin PBXProject section */ 90 | 5C99A5FF20A2DD080072FF66 /* Project object */ = { 91 | isa = PBXProject; 92 | attributes = { 93 | LastUpgradeCheck = 0930; 94 | ORGANIZATIONNAME = "Brian.W"; 95 | TargetAttributes = { 96 | 5C99A60620A2DD090072FF66 = { 97 | CreatedOnToolsVersion = 9.3; 98 | }; 99 | }; 100 | }; 101 | buildConfigurationList = 5C99A60220A2DD090072FF66 /* Build configuration list for PBXProject "awemeLib" */; 102 | compatibilityVersion = "Xcode 9.3"; 103 | developmentRegion = en; 104 | hasScannedForEncodings = 0; 105 | knownRegions = ( 106 | en, 107 | ); 108 | mainGroup = 5C99A5FE20A2DD080072FF66; 109 | productRefGroup = 5C99A60820A2DD090072FF66 /* Products */; 110 | projectDirPath = ""; 111 | projectRoot = ""; 112 | targets = ( 113 | 5C99A60620A2DD090072FF66 /* awemeLib */, 114 | ); 115 | }; 116 | /* End PBXProject section */ 117 | 118 | /* Begin PBXSourcesBuildPhase section */ 119 | 5C99A60320A2DD090072FF66 /* Sources */ = { 120 | isa = PBXSourcesBuildPhase; 121 | buildActionMask = 2147483647; 122 | files = ( 123 | 5C99A60D20A2DD090072FF66 /* awemeLib.m in Sources */, 124 | ); 125 | runOnlyForDeploymentPostprocessing = 0; 126 | }; 127 | /* End PBXSourcesBuildPhase section */ 128 | 129 | /* Begin XCBuildConfiguration section */ 130 | 5C99A60E20A2DD090072FF66 /* Debug */ = { 131 | isa = XCBuildConfiguration; 132 | buildSettings = { 133 | ALWAYS_SEARCH_USER_PATHS = NO; 134 | CLANG_ANALYZER_NONNULL = YES; 135 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 136 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 137 | CLANG_CXX_LIBRARY = "libc++"; 138 | CLANG_ENABLE_MODULES = YES; 139 | CLANG_ENABLE_OBJC_ARC = YES; 140 | CLANG_ENABLE_OBJC_WEAK = YES; 141 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 142 | CLANG_WARN_BOOL_CONVERSION = YES; 143 | CLANG_WARN_COMMA = YES; 144 | CLANG_WARN_CONSTANT_CONVERSION = YES; 145 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 146 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 147 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 148 | CLANG_WARN_EMPTY_BODY = YES; 149 | CLANG_WARN_ENUM_CONVERSION = YES; 150 | CLANG_WARN_INFINITE_RECURSION = YES; 151 | CLANG_WARN_INT_CONVERSION = YES; 152 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 153 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 154 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 155 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 156 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 157 | CLANG_WARN_STRICT_PROTOTYPES = YES; 158 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 159 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 160 | CLANG_WARN_UNREACHABLE_CODE = YES; 161 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 162 | CODE_SIGN_IDENTITY = "Mac Developer"; 163 | COPY_PHASE_STRIP = NO; 164 | DEBUG_INFORMATION_FORMAT = dwarf; 165 | ENABLE_STRICT_OBJC_MSGSEND = YES; 166 | ENABLE_TESTABILITY = YES; 167 | GCC_C_LANGUAGE_STANDARD = gnu11; 168 | GCC_DYNAMIC_NO_PIC = NO; 169 | GCC_NO_COMMON_BLOCKS = YES; 170 | GCC_OPTIMIZATION_LEVEL = 0; 171 | GCC_PREPROCESSOR_DEFINITIONS = ( 172 | "DEBUG=1", 173 | "$(inherited)", 174 | ); 175 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 176 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 177 | GCC_WARN_UNDECLARED_SELECTOR = YES; 178 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 179 | GCC_WARN_UNUSED_FUNCTION = YES; 180 | GCC_WARN_UNUSED_VARIABLE = YES; 181 | HEADER_SEARCH_PATHS = "/Users/SomePath/dev/decompile/IOSTools/Mantle/**"; 182 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 183 | MACOSX_DEPLOYMENT_TARGET = 10.11; 184 | MTL_ENABLE_DEBUG_INFO = YES; 185 | ONLY_ACTIVE_ARCH = YES; 186 | SDKROOT = iphoneos; 187 | }; 188 | name = Debug; 189 | }; 190 | 5C99A60F20A2DD090072FF66 /* Release */ = { 191 | isa = XCBuildConfiguration; 192 | buildSettings = { 193 | ALWAYS_SEARCH_USER_PATHS = NO; 194 | CLANG_ANALYZER_NONNULL = YES; 195 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 196 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 197 | CLANG_CXX_LIBRARY = "libc++"; 198 | CLANG_ENABLE_MODULES = YES; 199 | CLANG_ENABLE_OBJC_ARC = YES; 200 | CLANG_ENABLE_OBJC_WEAK = YES; 201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_COMMA = YES; 204 | CLANG_WARN_CONSTANT_CONVERSION = YES; 205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 207 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 208 | CLANG_WARN_EMPTY_BODY = YES; 209 | CLANG_WARN_ENUM_CONVERSION = YES; 210 | CLANG_WARN_INFINITE_RECURSION = YES; 211 | CLANG_WARN_INT_CONVERSION = YES; 212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 217 | CLANG_WARN_STRICT_PROTOTYPES = YES; 218 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 219 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 220 | CLANG_WARN_UNREACHABLE_CODE = YES; 221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 222 | CODE_SIGN_IDENTITY = "Mac Developer"; 223 | COPY_PHASE_STRIP = NO; 224 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 225 | ENABLE_NS_ASSERTIONS = NO; 226 | ENABLE_STRICT_OBJC_MSGSEND = YES; 227 | GCC_C_LANGUAGE_STANDARD = gnu11; 228 | GCC_NO_COMMON_BLOCKS = YES; 229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 231 | GCC_WARN_UNDECLARED_SELECTOR = YES; 232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 233 | GCC_WARN_UNUSED_FUNCTION = YES; 234 | GCC_WARN_UNUSED_VARIABLE = YES; 235 | HEADER_SEARCH_PATHS = "/Users/SomePath/dev/decompile/IOSTools/Mantle/**"; 236 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 237 | MACOSX_DEPLOYMENT_TARGET = 10.11; 238 | MTL_ENABLE_DEBUG_INFO = NO; 239 | ONLY_ACTIVE_ARCH = YES; 240 | SDKROOT = iphoneos; 241 | }; 242 | name = Release; 243 | }; 244 | 5C99A61120A2DD090072FF66 /* Debug */ = { 245 | isa = XCBuildConfiguration; 246 | buildSettings = { 247 | CODE_SIGN_IDENTITY = "iPhone Developer"; 248 | CODE_SIGN_STYLE = Automatic; 249 | DEVELOPMENT_TEAM = AFAL4YF522; 250 | DYLIB_COMPATIBILITY_VERSION = 1; 251 | DYLIB_CURRENT_VERSION = 1; 252 | EXECUTABLE_PREFIX = lib; 253 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 254 | PRODUCT_NAME = "$(TARGET_NAME)"; 255 | PROVISIONING_PROFILE_SPECIFIER = ""; 256 | SDKROOT = iphoneos; 257 | SKIP_INSTALL = YES; 258 | }; 259 | name = Debug; 260 | }; 261 | 5C99A61220A2DD090072FF66 /* Release */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | CODE_SIGN_IDENTITY = "iPhone Developer"; 265 | CODE_SIGN_STYLE = Automatic; 266 | DEVELOPMENT_TEAM = AFAL4YF522; 267 | DYLIB_COMPATIBILITY_VERSION = 1; 268 | DYLIB_CURRENT_VERSION = 1; 269 | EXECUTABLE_PREFIX = lib; 270 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 271 | PRODUCT_NAME = "$(TARGET_NAME)"; 272 | PROVISIONING_PROFILE_SPECIFIER = ""; 273 | SDKROOT = iphoneos; 274 | SKIP_INSTALL = YES; 275 | }; 276 | name = Release; 277 | }; 278 | /* End XCBuildConfiguration section */ 279 | 280 | /* Begin XCConfigurationList section */ 281 | 5C99A60220A2DD090072FF66 /* Build configuration list for PBXProject "awemeLib" */ = { 282 | isa = XCConfigurationList; 283 | buildConfigurations = ( 284 | 5C99A60E20A2DD090072FF66 /* Debug */, 285 | 5C99A60F20A2DD090072FF66 /* Release */, 286 | ); 287 | defaultConfigurationIsVisible = 0; 288 | defaultConfigurationName = Release; 289 | }; 290 | 5C99A61020A2DD090072FF66 /* Build configuration list for PBXNativeTarget "awemeLib" */ = { 291 | isa = XCConfigurationList; 292 | buildConfigurations = ( 293 | 5C99A61120A2DD090072FF66 /* Debug */, 294 | 5C99A61220A2DD090072FF66 /* Release */, 295 | ); 296 | defaultConfigurationIsVisible = 0; 297 | defaultConfigurationName = Release; 298 | }; 299 | /* End XCConfigurationList section */ 300 | }; 301 | rootObject = 5C99A5FF20A2DD080072FF66 /* Project object */; 302 | } 303 | -------------------------------------------------------------------------------- /ios_aweme_lib/awemeLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios_aweme_lib/awemeLib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios_aweme_lib/awemeLib/awemeLib.h: -------------------------------------------------------------------------------- 1 | // 2 | // awemeLib.h 3 | // awemeLib 4 | // 5 | // Created by Brian.W on 2018/5/9. 6 | // Copyright © 2018年 Brian.W. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface awemeLib : NSObject 14 | 15 | @end 16 | 17 | @class IESAntiSpamConfig; 18 | @interface IESAntiSpam : NSObject 19 | { 20 | _Bool _isStarted; 21 | _Bool _isInitialized; 22 | id _IESAntiSpamDeviceIDBlock; 23 | IESAntiSpamConfig *_config; 24 | long long _serverTime; 25 | long long _localTime; 26 | } 27 | 28 | + (id)convertDataToHexString:(id)arg1; 29 | + (id)deviceID; 30 | + (id)encryptDataWithTimeStamp:(int)arg1 parameters:(id)arg2; 31 | + (id)sharedInstance; 32 | @property long long localTime; // @synthesize localTime=_localTime; 33 | @property long long serverTime; // @synthesize serverTime=_serverTime; 34 | @property(nonatomic) _Bool isInitialized; // @synthesize isInitialized=_isInitialized; 35 | @property(nonatomic) _Bool isStarted; // @synthesize isStarted=_isStarted; 36 | @property(retain, nonatomic) IESAntiSpamConfig *config; // @synthesize config=_config; 37 | @property(copy, nonatomic) id IESAntiSpamDeviceIDBlock; // @synthesize IESAntiSpamDeviceIDBlock=_IESAntiSpamDeviceIDBlock; 38 | //- (void).cxx_destruct; 39 | - (void)addjustWithServerTime:(long long)arg1; 40 | - (id)encryptURLWithURL:(id)arg1 formData:(id)arg2; 41 | - (id)adjustWithAntiSpamResponse:(id)arg1 previousConfig:(id)arg2; 42 | - (void)fetchSettingsWithConfig:(id)arg1; 43 | - (void)startWithConfig:(id)arg1; 44 | - (id)init; 45 | 46 | @end 47 | 48 | @class NSString; 49 | 50 | @interface IESAntiSpamConfig : MTLModel 51 | { 52 | NSString *_appID; 53 | NSString *_spname; 54 | NSString *_secretKey; 55 | NSString *_configURL; 56 | } 57 | 58 | + (id)configWithAppID:(id)arg1 spname:(id)arg2 secretKey:(id)arg3; 59 | @property(copy, nonatomic) NSString *configURL; // @synthesize configURL=_configURL; 60 | @property(copy, nonatomic) NSString *secretKey; // @synthesize secretKey=_secretKey; 61 | @property(copy, nonatomic) NSString *spname; // @synthesize spname=_spname; 62 | @property(copy, nonatomic) NSString *appID; // @synthesize appID=_appID; 63 | //- (void).cxx_destruct; 64 | - (id)init; 65 | 66 | @end 67 | 68 | 69 | 70 | 71 | //extern int test(int a, int b); 72 | -------------------------------------------------------------------------------- /ios_aweme_lib/awemeLib/awemeLib.m: -------------------------------------------------------------------------------- 1 | // 2 | // awemeLib.m 3 | // awemeLib 4 | // 5 | // Created by Brian.W on 2018/5/9. 6 | // Copyright © 2018年 Brian.W. All rights reserved. 7 | // 8 | #import 9 | #import 10 | #import 11 | #import 12 | //#import 13 | #import 14 | 15 | #import 16 | #import 17 | #import 18 | #import "awemeLib.h" 19 | 20 | @implementation awemeLib 21 | 22 | @end 23 | 24 | int test(int a, int b){ 25 | return a + b; 26 | } 27 | 28 | const char* testchar(char *paramaJsonStr){ 29 | NSString *paramaJsonN = [NSString stringWithUTF8String:paramaJsonStr]; 30 | //NSLog(@"paramaJsonN = %@", paramaJsonN); 31 | NSData *paramaJsonD = [paramaJsonN dataUsingEncoding:NSUTF8StringEncoding]; 32 | NSDictionary *paramaJson = [NSJSONSerialization JSONObjectWithData:paramaJsonD options:0 error:nil]; 33 | NSError *parseError = nil; 34 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:paramaJson options:NSJSONWritingPrettyPrinted error:&parseError]; 35 | NSString *str= [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 36 | const char* c = [str UTF8String]; 37 | return c; 38 | } 39 | 40 | const char* encryptDataWithTimeStamp(char *paramaJsonStr, int timeStamp, char *deviceIDStr, char *libPath) { 41 | NSString *paramaJsonN = [NSString stringWithUTF8String:paramaJsonStr]; 42 | //NSLog(@"paramaJsonN = %@", paramaJsonN); 43 | NSData *paramaJsonD = [paramaJsonN dataUsingEncoding:NSUTF8StringEncoding]; 44 | id paramaJson = [NSJSONSerialization JSONObjectWithData:paramaJsonD options:0 error:nil]; 45 | //NSString * dylibName = @"Awemex64"; 46 | //NSString * path = [[NSBundle mainBundle] pathForResource:dylibName ofType:@"dylib"]; 47 | NSFileManager *filemgr; 48 | NSString *currentpath; 49 | filemgr = [[NSFileManager alloc] init]; 50 | currentpath = [filemgr currentDirectoryPath]; 51 | NSString * path = [NSString stringWithFormat:@"%@%s", currentpath, libPath ]; 52 | //NSLog(@"dlopen path=%@", path); 53 | if (dlopen(path.UTF8String, RTLD_NOW) == NULL){ 54 | NSLog(@"dlopen failed ,error %s", dlerror()); 55 | return 0; 56 | }; 57 | uint32_t dylib_count = _dyld_image_count(); 58 | uint64_t slide = 0; 59 | for (int i = 0; i < dylib_count; i ++) { 60 | const char * name = _dyld_get_image_name(i); 61 | if ([[NSString stringWithUTF8String:name] isEqualToString:path]) { 62 | slide = _dyld_get_image_vmaddr_slide(i); 63 | } 64 | //NSLog(@"dylib path = %@", [NSString stringWithUTF8String:name]); 65 | } 66 | assert(slide != 0); 67 | int arg1 = timeStamp; 68 | NSString * deviceID = [NSString stringWithCString:deviceIDStr encoding:NSUTF8StringEncoding]; 69 | Class IESAntiSpamConfigClass = NSClassFromString(@"IESAntiSpamConfig"); 70 | IESAntiSpamConfig *IESAntiSpamConfigInstance = [[IESAntiSpamConfigClass alloc]init]; 71 | [IESAntiSpamConfigInstance setConfigURL:@"https://hotsoon.snssdk.com/hotsoon/sp/"]; 72 | [IESAntiSpamConfigInstance setSecretKey:@"a3668f0afac72ca3f6c1697d29e0e1bb1fef4ab0285319b95ac39fa42c38d05f"]; 73 | [IESAntiSpamConfigInstance setSpname:@"aweme"]; 74 | [IESAntiSpamConfigInstance setAppID:@"1128"]; 75 | Class IESAntiSpamClass = NSClassFromString(@"IESAntiSpam"); 76 | IESAntiSpam *instance = [IESAntiSpamClass sharedInstance]; 77 | // id (^callBack)() = ^id(){ 78 | // return nil; 79 | // }; 80 | // callBack = [instance IESAntiSpamDeviceIDBlock]; 81 | [instance startWithConfig:IESAntiSpamConfigInstance]; 82 | [instance setIESAntiSpamDeviceIDBlock:^id(){ 83 | //return nil; 84 | return [NSString stringWithString:deviceID]; 85 | }]; 86 | //id deviceID_id = [IESAntiSpamClass deviceID]; 87 | id arg2 = paramaJson; 88 | // [instance setLocalTime:arg1]; 89 | // [instance setServerTime:arg1]; 90 | // long long LocalTime = [instance localTime]; 91 | // long long ServerTime = [instance serverTime]; 92 | // [instance setIsInitialized:true]; 93 | // [instance setIsStarted:true]; 94 | //NSDictionary *rst = [IESAntiSpamClass performSelector:NSSelectorFromString(@"encryptDataWithTimeStamp:parameters:") withObject:arg1 withObject:dict]; 95 | //NSLog(@"test"); 96 | NSDictionary *rst = [IESAntiSpamClass encryptDataWithTimeStamp:arg1 parameters: arg2]; 97 | NSError *parseError = nil; 98 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:rst options:NSJSONWritingPrettyPrinted error:&parseError]; 99 | NSString *str= [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 100 | const char* c = [str UTF8String]; 101 | return c; 102 | } 103 | -------------------------------------------------------------------------------- /ios_webserver/awemeDylib.h: -------------------------------------------------------------------------------- 1 | // weibo: http://weibo.com/xiaoqing28 2 | // blog: http://www.alonemonkey.com 3 | // 4 | // usual_awemeDylib.h 5 | // usual.awemeDylib 6 | // 7 | // Created by Brian.W on 2018/3/24. 8 | // Copyright (c) 2018年 Brian.W. All rights reserved. 9 | // 10 | 11 | #import 12 | #import 13 | #import "GCDWebServer.h" 14 | #import "GCDWebServerDataResponse.h" 15 | #import "GCDWebServerURLEncodedFormRequest.h" 16 | 17 | #define INSERT_SUCCESS_WELCOME @"\n 🎉!!!congratulations!!!🎉\n👍----------------insert dylib success----------------👍" 18 | 19 | @interface CustomViewController 20 | 21 | @property (nonatomic, copy) NSString* newProperty; 22 | 23 | + (void)classMethod; 24 | 25 | - (NSString*)getMyName; 26 | 27 | - (void)newMethod:(NSString*) output; 28 | 29 | @end 30 | 31 | @interface TTDefaultHTTPRequestSerializer 32 | { 33 | NSString *_defaultUserAgent; 34 | } 35 | 36 | - (void)testMethod:(NSString*) output; 37 | + (id)serializer; 38 | @property(copy, nonatomic) NSString *defaultUserAgent; // @synthesize defaultUserAgent=_defaultUserAgent; 39 | //- (void).cxx_destruct; 40 | - (void)applyCookieHeaderFrom:(id)arg1 toRequest:(id)arg2; 41 | - (void)applyCookieHeader:(id)arg1; 42 | - (id)defaultUserAgentString; 43 | - (void)buildRequestHeaders:(id)arg1 parameters:(id)arg2; 44 | - (void)buildRequestHeaders:(id)arg1; 45 | - (id)_transferedURL:(id)arg1; 46 | - (id)URLRequestWithRequestModel:(id)arg1 commonParams:(id)arg2; 47 | - (id)URLRequestWithURL:(id)arg1 headerField:(id)arg2 params:(id)arg3 method:(id)arg4 constructingBodyBlock:(int)arg5 commonParams:(id)arg6; 48 | - (id)URLRequestWithURL:(id)arg1 params:(id)arg2 method:(id)arg3 constructingBodyBlock:(int)arg4 commonParams:(id)arg5; 49 | 50 | @end 51 | 52 | @interface TTTInstallIDPostDataHttpRequestSerializer: TTDefaultHTTPRequestSerializer 53 | - (id)URLRequestWithURL:(id)arg1 params:(id)arg2 method:(id)arg3 constructingBodyBlock:(int)arg4 commonParams:(id)arg5; 54 | @end 55 | 56 | @interface IESAntiSpam : NSObject 57 | { 58 | struct _opaque_pthread_rwlock_t rwlock; 59 | _Bool _isInitialized; 60 | id _NWY2ZjI3Y2ZiYjQzNTA5YjRjNDA2NTQ0ZDU3MjVmMWYgIC0K; 61 | long long _MWIyMDgyNjM1YmRlZWY3YzFjMDAyODllYmE2ZTJiYzYgIC0K; 62 | long long _MWM3YjBlMDZmZmFhZGQ0NzBhNzdmOGEzODcwZDRhYzcgIC0K; 63 | } 64 | 65 | + (id)convertDataToHexString:(id)arg1; 66 | + (id)deviceID; 67 | + (id)encryptDataWithTimeStamp:(long long)arg1 parameters:(id)arg2; 68 | + (id)sharedInstance; 69 | @property(nonatomic) _Bool isInitialized; // @synthesize isInitialized=_isInitialized; 70 | @property long long MWM3YjBlMDZmZmFhZGQ0NzBhNzdmOGEzODcwZDRhYzcgIC0K; // @synthesize MWM3YjBlMDZmZmFhZGQ0NzBhNzdmOGEzODcwZDRhYzcgIC0K=_MWM3YjBlMDZmZmFhZGQ0NzBhNzdmOGEzODcwZDRhYzcgIC0K; 71 | @property long long MWIyMDgyNjM1YmRlZWY3YzFjMDAyODllYmE2ZTJiYzYgIC0K; // @synthesize MWIyMDgyNjM1YmRlZWY3YzFjMDAyODllYmE2ZTJiYzYgIC0K=_MWIyMDgyNjM1YmRlZWY3YzFjMDAyODllYmE2ZTJiYzYgIC0K; 72 | @property(copy, nonatomic) id NWY2ZjI3Y2ZiYjQzNTA5YjRjNDA2NTQ0ZDU3MjVmMWYgIC0K; // @synthesize NWY2ZjI3Y2ZiYjQzNTA5YjRjNDA2NTQ0ZDU3MjVmMWYgIC0K=_NWY2ZjI3Y2ZiYjQzNTA5YjRjNDA2NTQ0ZDU3MjVmMWYgIC0K; 73 | - (id)Y2MxYWIwMTRlN2E1NWE1OWU3ZDVjZDAwMjJlNzc2ZDYgIC0K:(id)arg1 formData:(id)arg2; 74 | - (void)adjustWithServerTime:(long long)arg1; 75 | - (void)startConfig; 76 | - (id)init; 77 | 78 | @end 79 | 80 | 81 | //@class IESAntiSpamConfig; 82 | //@interface IESAntiSpam : NSObject 83 | //{ 84 | // _Bool _isStarted; 85 | // _Bool _isInitialized; 86 | // id _IESAntiSpamDeviceIDBlock; 87 | // IESAntiSpamConfig *_config; 88 | // long long _serverTime; 89 | // long long _localTime; 90 | //} 91 | // 92 | //+ (id)convertDataToHexString:(id)arg1; 93 | //+ (id)deviceID; 94 | //+ (id)encryptDataWithTimeStamp:(int)arg1 parameters:(id)arg2; 95 | //+ (id)sharedInstance; 96 | //@property long long localTime; // @synthesize localTime=_localTime; 97 | //@property long long serverTime; // @synthesize serverTime=_serverTime; 98 | //@property(nonatomic) _Bool isInitialized; // @synthesize isInitialized=_isInitialized; 99 | //@property(nonatomic) _Bool isStarted; // @synthesize isStarted=_isStarted; 100 | //@property(retain, nonatomic) IESAntiSpamConfig *config; // @synthesize config=_config; 101 | //@property(copy, nonatomic) id IESAntiSpamDeviceIDBlock; // @synthesize IESAntiSpamDeviceIDBlock=_IESAntiSpamDeviceIDBlock; 102 | ////- (void).cxx_destruct; 103 | //- (void)addjustWithServerTime:(long long)arg1; 104 | //- (id)encryptURLWithURL:(id)arg1 formData:(id)arg2; 105 | //- (id)adjustWithAntiSpamResponse:(id)arg1 previousConfig:(id)arg2; 106 | //- (void)fetchSettingsWithConfig:(id)arg1; 107 | //- (void)startWithConfig:(id)arg1; 108 | //- (id)init; 109 | // 110 | //@end 111 | 112 | @interface N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K : NSObject 113 | { 114 | _Bool _enabledLocated; 115 | _Bool _requestSettings; 116 | unsigned long long _platform; 117 | Class _delegate; 118 | NSThread *_workerThread; 119 | //SGMSensorManager *_timerSensor; 120 | //SGMSensorManager *_manualSensor; 121 | //NTJjMDRlZThlYzNiYjMzZWU4MjQ3MWNhODIzNWZjNmEgIC0K *_logManager; 122 | NSTimer *_timer; 123 | //CLLocationManager *_locationManager; 124 | NSObject *_lock; 125 | NSString *_scene; 126 | //SGMSafeGuardSettingModel *_settings; 127 | //struct CLLocationCoordinate2D _currentCoordinate; 128 | } 129 | 130 | + (id)sharedManager; 131 | @property(nonatomic) _Bool requestSettings; // @synthesize requestSettings=_requestSettings; 132 | //@property(retain, nonatomic) SGMSafeGuardSettingModel *settings; // @synthesize settings=_settings; 133 | @property(copy, nonatomic) NSString *scene; // @synthesize scene=_scene; 134 | @property(retain, nonatomic) NSObject *lock; // @synthesize lock=_lock; 135 | @property(nonatomic) _Bool enabledLocated; // @synthesize enabledLocated=_enabledLocated; 136 | @property(nonatomic) struct CLLocationCoordinate2D currentCoordinate; // @synthesize currentCoordinate=_currentCoordinate; 137 | //@property(retain, nonatomic) CLLocationManager *locationManager; // @synthesize locationManager=_locationManager; 138 | @property(retain, nonatomic) NSTimer *timer; // @synthesize timer=_timer; 139 | //@property(retain, nonatomic) NTJjMDRlZThlYzNiYjMzZWU4MjQ3MWNhODIzNWZjNmEgIC0K *logManager; // @synthesize logManager=_logManager; 140 | //@property(retain, nonatomic) SGMSensorManager *manualSensor; // @synthesize manualSensor=_manualSensor; 141 | //@property(retain, nonatomic) SGMSensorManager *timerSensor; // @synthesize timerSensor=_timerSensor; 142 | @property(retain, nonatomic) NSThread *workerThread; // @synthesize workerThread=_workerThread; 143 | @property(nonatomic) __weak Class delegate; // @synthesize delegate=_delegate; 144 | @property(nonatomic) unsigned long long platform; // @synthesize platform=_platform; 145 | //- (void).cxx_destruct; 146 | - (id)getStringTypeInfoFromDelegateSelector:(SEL)arg1; 147 | - (id)safeString:(id)arg1; 148 | - (void)p_asyncPerformSelector:(SEL)arg1 withObject:(id)arg2; 149 | - (void)threadRun; 150 | - (id)dataUploadURLOfPlatform:(unsigned long long)arg1; 151 | - (id)settingsURLOfPlatform:(unsigned long long)arg1; 152 | - (id)modelOfJSON:(id)arg1; 153 | - (void)p_stopScheduledTask; 154 | - (void)p_updateSensorInterval:(id)arg1; 155 | - (void)updateSettings:(id)arg1; 156 | - (double)timestampForDate:(id)arg1; 157 | - (_Bool)isLocationServiceOpen; 158 | - (id)getCurrentCoordinateOfUser; 159 | - (id)p_fetchSecSDKInfo; 160 | - (id)p_fetchDeviceInfo; 161 | - (id)p_fetchSensorInfo; 162 | - (id)p_fetchUploadDataForScene:(id)arg1; 163 | - (id)preprocessDataForScene:(id)arg1; 164 | - (void)p_uploadDataForScene:(id)arg1; 165 | - (void)p_schedulSGUpload; 166 | - (void)p_stop; 167 | - (void)p_startForScene:(id)arg1; 168 | - (void)p_schedulSafeGuard; 169 | - (void)p_requestSettingsWithCompletion:(id)arg1; 170 | - (void)p_saveAccelerometerData:(id)arg1; 171 | - (void)p_saveGyroData:(id)arg1; 172 | - (void)locationManager:(id)arg1 didFailWithError:(id)arg2; 173 | - (void)locationManager:(id)arg1 didUpdateLocations:(id)arg2; 174 | - (void)MmY2YWEzYjI0YzdkYmU4OGUwM2UyM2U2YTNkYmJjODAgIC0K:(id)arg1 updateAccelerometerData:(id)arg2; 175 | - (void)MmY2YWEzYjI0YzdkYmU4OGUwM2UyM2U2YTNkYmJjODAgIC0K:(id)arg1 updateGyroData:(id)arg2; 176 | - (void)p_innerScheduleSafeGuard; 177 | - (id)ODU2M2Y2Y2EzZmU4ZWZkZDJmYzA3MzAwYzEyZmM2MzcgIC0K:(id)arg1; 178 | - (void)N2VhMzY3MTA2YWJiOGEzNDgwMTdlYzRmNmFkMDI1NWYgIC0K; 179 | - (void)NTgxNWY4YTI5MWI4YmUzOGJiNjU4NjkyMzM1NDA0ZjkgIC0K:(id)arg1; 180 | - (void)NjNkZDA0ZTYxYThiZWRlNGQyM2YwM2NhNDlhMWQ1MmQgIC0K; 181 | - (void)ZjBkYzVlNTJhMTZjOTg0YmI2NmYwOGE0OWYzMjQ5MWEgIC0K:(Class)arg1; 182 | - (id)init; 183 | 184 | // Remaining properties 185 | @property(readonly, copy) NSString *debugDescription; 186 | @property(readonly, copy) NSString *description; 187 | @property(readonly) unsigned long long hash; 188 | @property(readonly) Class superclass; 189 | 190 | @end 191 | 192 | @class NSString; 193 | 194 | @interface IESAntiSpamConfig : MTLModel 195 | { 196 | NSString *_appID; 197 | NSString *_spname; 198 | NSString *_secretKey; 199 | NSString *_configURL; 200 | } 201 | 202 | + (id)configWithAppID:(id)arg1 spname:(id)arg2 secretKey:(id)arg3; 203 | @property(copy, nonatomic) NSString *configURL; // @synthesize configURL=_configURL; 204 | @property(copy, nonatomic) NSString *secretKey; // @synthesize secretKey=_secretKey; 205 | @property(copy, nonatomic) NSString *spname; // @synthesize spname=_spname; 206 | @property(copy, nonatomic) NSString *appID; // @synthesize appID=_appID; 207 | //- (void).cxx_destruct; 208 | - (id)init; 209 | 210 | @end 211 | 212 | @interface TTInstallOpenUDID : NSObject 213 | { 214 | } 215 | 216 | + (id)valueWithError:(id *)arg1; 217 | + (id)value; 218 | + (id)_getOpenUDID; 219 | + (id)_getDictFromPasteboard:(id)arg1; 220 | + (void)_setDict:(id)arg1 forPasteboard:(id)arg2; 221 | 222 | @end 223 | 224 | 225 | @interface AWELocationService : NSObject 226 | { 227 | } 228 | 229 | + (id)sharedInstance; 230 | + (id)base64StringWithDictionary:(id)arg1; 231 | + (id)districtForPlacemark:(id)arg1; 232 | + (id)cityForPlacemark:(id)arg1; 233 | + (void)uploadLocationWithName:(id)arg1 completion:(id)arg2; 234 | + (void)_uploadLocation:(id)arg1 placemark:(id)arg2 completion:(id)arg3; 235 | + (void)uploadLocation:(id)arg1 completion:(id)arg2; 236 | - (void)setSystemLocationAlertShowned; 237 | - (_Bool)isSystemLocationAlertShowned; 238 | - (_Bool)clearLocation; 239 | - (_Bool)persistLocation:(id)arg1; 240 | - (void)requestCurrentLocationWithAccuracy:(long long)arg1 completionBlock:(id)arg2; 241 | - (void)requestCurrentLocation:(id)arg1; 242 | - (void)requestPermission:(id)arg1; 243 | - (id)currentLocation; 244 | - (_Bool)hasPermission; 245 | 246 | @end 247 | 248 | 249 | @class NSString; 250 | 251 | @interface AWESecurityLaunchTask : NSObject 252 | { 253 | } 254 | 255 | + (id)sharedInstance; 256 | + (void)onAppLaunch; 257 | - (void)awes_showAppStoreDownloadAlert:(id)arg1; 258 | - (_Bool)awes_isUseTTNet; 259 | - (id)awes_currentLocation; 260 | - (id)awes_installChannel; 261 | - (id)awes_sessionID; 262 | - (id)awes_installID; 263 | - (id)awes_customDeviceID; 264 | - (void)didReceiveApiResponse:(id)arg1 URL:(id)arg2; 265 | - (void)startLoader; 266 | - (void)dealloc; 267 | - (id)init; 268 | 269 | // Remaining properties 270 | @property(readonly, copy) NSString *debugDescription; 271 | @property(readonly, copy) NSString *description; 272 | @property(readonly) unsigned long long hash; 273 | @property(readonly) Class superclass; 274 | 275 | @end 276 | 277 | @interface Utils : NSObject 278 | - (NSString *)convertToJsonData:(NSDictionary *)dict 279 | @end 280 | -------------------------------------------------------------------------------- /ios_webserver/awemeDylib.m: -------------------------------------------------------------------------------- 1 | // weibo: http://weibo.com/xiaoqing28 2 | // blog: http://www.alonemonkey.com 3 | // 4 | // usual_awemeDylib.m 5 | // usual.awemeDylib 6 | // 7 | // Created by Brian.W on 2018/3/24. 8 | // Copyright (c) 2018年 Brian.W. All rights reserved. 9 | // 10 | 11 | #import "awemeDylib.h" 12 | #import 13 | #import 14 | #import 15 | #import 16 | 17 | CHConstructor{ 18 | NSLog(INSERT_SUCCESS_WELCOME); 19 | 20 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { 21 | 22 | #ifndef __OPTIMIZE__ 23 | CYListenServer(6666); 24 | #endif 25 | 26 | }]; 27 | } 28 | 29 | 30 | 31 | CHDeclareClass(CustomViewController) 32 | CHDeclareClass(TTDefaultHTTPRequestSerializer) 33 | CHDeclareClass(TTTInstallIDPostDataHttpRequestSerializer) 34 | CHDeclareClass(NSData) 35 | CHDeclareClass(NSMutableDictionary) 36 | CHDeclareClass(IESAntiSpam) 37 | CHDeclareClass(N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K) 38 | CHDeclareClass(TTInstallOpenUDID) 39 | CHDeclareClass(AWELocationService) 40 | CHDeclareClass(AWESecurityLaunchTask) 41 | 42 | #pragma clang diagnostic push 43 | #pragma clang diagnostic ignored "-Wstrict-prototypes" 44 | 45 | //add new method 46 | CHDeclareMethod1(void, CustomViewController, newMethod, NSString*, output){ 47 | NSLog(@"This is a new method : %@", output); 48 | } 49 | 50 | CHDeclareMethod1(void, TTDefaultHTTPRequestSerializer, testMethod, NSString*, output){ 51 | NSLog(@"This is a new method : %@", output); 52 | } 53 | 54 | 55 | 56 | #pragma clang diagnostic pop 57 | 58 | CHOptimizedClassMethod0(self, void, CustomViewController, classMethod){ 59 | NSLog(@"hook class method"); 60 | CHSuper0(CustomViewController, classMethod); 61 | } 62 | 63 | //CHOptimizedClassMethod1(optimization, return_type, class_type, name1, type1, arg1) 64 | CHOptimizedClassMethod2(self, id, NSData, dataWithBytesNoCopy, void *, arg_bytes, length, NSUInteger, arg_length){ 65 | // if (arg_length == 596) { 66 | // NSLog(@"hook class dataWithBytesNoCopy"); 67 | // } 68 | return CHSuper2(NSData, dataWithBytesNoCopy, arg_bytes, length, arg_length); 69 | } 70 | 71 | 72 | 73 | //CHOptimizedMethod1(optimization, return_type, class_type, name1, type1, arg1) 74 | //CHMethod1(return_type, class_type, name1, type1, arg1) 75 | CHOptimizedClassMethod0(self, id, TTDefaultHTTPRequestSerializer, serializer){ 76 | NSLog(@"hook class TTDefaultHTTPRequestSerializer:serializer"); 77 | //get property 78 | // NSString* UA = CHIvar(self,defaultUserAgent,__strong NSString*); 79 | // NSLog(@"hook :defaultUserAgent is %@",UA); 80 | return CHSuper0(TTDefaultHTTPRequestSerializer, serializer); 81 | } 82 | 83 | CHOptimizedClassMethod1(self, id, AWELocationService, base64StringWithDictionary, id, arg1){ 84 | NSLog(@"hook class AWELocationService:base64StringWithDictionary"); 85 | id rst = CHSuper1(AWELocationService, base64StringWithDictionary, arg1); 86 | return rst; 87 | } 88 | 89 | CHOptimizedMethod1(self, id, AWESecurityLaunchTask, awes_showAppStoreDownloadAlert,id,arg1){ 90 | NSLog(@"hook class AWESecurityLaunchTask:awes_showAppStoreDownloadAlert"); 91 | return nil; 92 | 93 | } 94 | 95 | //CHOptimizedClassMethod2(optimization, return_type, class_type, name1, type1, arg1, name2, type2, arg2) 96 | CHOptimizedClassMethod2(self, id, IESAntiSpam, encryptDataWithTimeStamp, int, arg1, parameters, id, arg2){ 97 | NSLog(@"hook class IESAntiSpam:encryptDataWithTimeStamp"); 98 | //[Utils] 99 | GCDWebServer* _webServer; 100 | _webServer = [[GCDWebServer alloc] init]; 101 | 102 | // Add a handler to respond to GET requests on any URL 103 | [_webServer addDefaultHandlerForMethod:@"GET" 104 | requestClass:[GCDWebServerRequest class] 105 | processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) { 106 | 107 | 108 | return [GCDWebServerDataResponse responseWithHTML:@"

Hello World

"]; 109 | 110 | }]; 111 | [_webServer addHandlerForMethod:@"POST" 112 | path:@"/encryptDataWithTimeStamp" 113 | requestClass:[GCDWebServerURLEncodedFormRequest class] 114 | processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) { 115 | NSString* paramaJson_str = [[(GCDWebServerURLEncodedFormRequest*)request arguments] objectForKey:@"paramaJson"]; 116 | NSString* timeStamp_str = [[(GCDWebServerURLEncodedFormRequest*)request arguments] objectForKey:@"timeStamp"]; 117 | int timeStamp_int = timeStamp_str.intValue; 118 | NSError *jsonError; 119 | NSData *objectData = [paramaJson_str dataUsingEncoding:NSUTF8StringEncoding]; 120 | NSDictionary *paramaJson_dict = [NSJSONSerialization JSONObjectWithData:objectData 121 | options:NSJSONReadingMutableContainers 122 | error:&jsonError]; 123 | NSString* deviceID = [paramaJson_dict objectForKey:@"device_id"]; 124 | IESAntiSpam *instance = [self sharedInstance]; 125 | bool is_inited = [instance isInitialized]; 126 | id deviceID_id = [self deviceID]; 127 | //id IESAntiSpamDeviceIDBlock = [instance NWY2ZjI3Y2ZiYjQzNTA5YjRjNDA2NTQ0ZDU3MjVmMWYgIC0K]; 128 | [instance setNWY2ZjI3Y2ZiYjQzNTA5YjRjNDA2NTQ0ZDU3MjVmMWYgIC0K:^id(){ 129 | //return nil; 130 | return [NSString stringWithString:deviceID]; 131 | }]; 132 | NSDictionary *rst = CHSuper2(IESAntiSpam, encryptDataWithTimeStamp, timeStamp_int, parameters, paramaJson_dict); 133 | NSString *rst_str = [NSString stringWithFormat:@"%@", rst]; 134 | NSString* html = [NSString stringWithFormat:@"%@", rst_str]; 135 | return [GCDWebServerDataResponse responseWithHTML:html]; 136 | 137 | }]; 138 | // Start server on port 8080 139 | [_webServer startWithPort:8080 bonjourName:nil]; 140 | NSLog(@"Visit %@ in your web browser", _webServer.serverURL); 141 | do { 142 | sleep(99999); 143 | }while(1); 144 | 145 | return nil; 146 | } 147 | 148 | CHOptimizedClassMethod0(self, id, TTTInstallIDPostDataHttpRequestSerializer, serializer){ 149 | NSLog(@"hook class TTTInstallIDPostDataHttpRequestSerializer:serializer"); 150 | //get property 151 | // NSString* UA = CHIvar(self,defaultUserAgent,__strong NSString*); 152 | // NSLog(@"hook :defaultUserAgent is %@",UA); 153 | return CHSuper0(TTTInstallIDPostDataHttpRequestSerializer, serializer); 154 | } 155 | 156 | CHOptimizedClassMethod0(self, id, TTInstallOpenUDID, _getOpenUDID){ 157 | NSLog(@"hook class OpenUDID:_getOpenUDID"); 158 | id rst = CHSuper0(TTInstallOpenUDID, _getOpenUDID); 159 | return rst; 160 | } 161 | 162 | CHOptimizedClassMethod1(self, id, TTInstallOpenUDID, valueWithError, id*, arg1){ 163 | NSLog(@"hook class OpenUDID:valueWithError"); 164 | id rst = CHSuper1(TTInstallOpenUDID, valueWithError, arg1); 165 | return rst; 166 | } 167 | 168 | //CHOptimizedClassMethod5(optimization, return_type, class_type, name1, type1, arg1, name2, type2, arg2, name3, type3, arg3, name4, type4, arg4, name5, type5, arg5) 169 | //CHOptimizedMethod5(optimization, return_type, class_type, name1, type1, arg1, name2, type2, arg2, name3, type3, arg3, name4, type4, arg4, name5, type5, arg5) 170 | CHOptimizedMethod5(self, id, TTTInstallIDPostDataHttpRequestSerializer, URLRequestWithURL,id,arg1, params, id, arg2, method, id, arg3, constructingBodyBlock, id, arg4, commonParams, id, arg5){ 171 | NSLog(@"hook class TTTInstallIDPostDataHttpRequestSerializer:URLRequestWithURL"); 172 | //CHSuper5(class_type, name1, val1, name2, val2, name3, val3, name4, val4, name5, val5) 173 | return CHSuper5(TTTInstallIDPostDataHttpRequestSerializer, URLRequestWithURL, arg1, params, arg2, method, arg3, constructingBodyBlock, arg4, commonParams, arg5); 174 | } 175 | 176 | CHOptimizedMethod2(self, id, IESAntiSpam, encryptURLWithURL,id,arg1, formData, id, arg2){ 177 | NSLog(@"hook class IESAntiSpam:encryptURLWithURL"); 178 | // //id deviceID = [self deviceID]; 179 | // long long localTime = [self localTime]; 180 | // long long serverTime = [self serverTime]; 181 | // IESAntiSpamConfig *config = [self config]; 182 | // NSDictionary *dict = @{ 183 | // @"type" : @"34" , 184 | // @"mobile" : @"2e3d333436373737323c33363330" , 185 | // @"mix_mode" : @1 186 | // }; 187 | // arg2 = dict; 188 | // NSURL *url = [NSURL URLWithString:@"https://lf.snssdk.com/passport/mobile/send_code/?iid=38131214263&ac=WIFI&os_api=18&app_name=aweme&channel=App%20Store&idfa=DFCF4ABE-ECEB-4FCC-87D6-710CB1C2A9C2&device_platform=iphone&build_number=17909&vid=FF7C3882-1526-4062-B137-4DB562DE72B5&openudid=f2c0da6bb76719cb83d4eebf57cb5c8ad3a1c810&device_type=iPhone7,2&app_version=1.7.9&device_id=54728286568&version_code=1.7.9&os_version=9.2.1&screen_width=750&aid=1128&mix_mode=1&mobile=2e3d333436373737323c33363330&type=34"]; 189 | // arg1 = url; 190 | id rst = CHSuper2(IESAntiSpam, encryptURLWithURL, arg1, formData, arg2); 191 | return rst; 192 | 193 | } 194 | CHOptimizedMethod2(self, void, NSMutableDictionary, setObject, id, obj, forKeyedSubscript, id, key){ 195 | 196 | // NSLog(@"hook class NSMutableDictionary:setObject"); 197 | // if (key==CFSTR("as")){ 198 | // printf("test"); 199 | // } 200 | CHSuper2(NSMutableDictionary, setObject, obj, forKeyedSubscript, key); 201 | } 202 | CHOptimizedMethod0(self, NSString*, CustomViewController, getMyName){ 203 | //get origin value 204 | NSString* originName = CHSuper(0, CustomViewController, getMyName); 205 | 206 | NSLog(@"origin name is:%@",originName); 207 | 208 | //get property 209 | NSString* password = CHIvar(self,_password,__strong NSString*); 210 | 211 | NSLog(@"password is %@",password); 212 | 213 | [self newMethod:@"output"]; 214 | 215 | //set new property 216 | self.newProperty = @"newProperty"; 217 | 218 | NSLog(@"newProperty : %@", self.newProperty); 219 | 220 | //change the value 221 | return @"AloneMonkey"; 222 | 223 | } 224 | //CHOptimizedMethod1(optimization, return_type, class_type, name1, type1, arg1) 225 | CHOptimizedMethod1(self, id, N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K, ODU2M2Y2Y2EzZmU4ZWZkZDJmYzA3MzAwYzEyZmM2MzcgIC0K,id,arg1){ 226 | NSLog(@"hook class N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K:ODU2M2Y2Y2EzZmU4ZWZkZDJmYzA3MzAwYzEyZmM2MzcgIC0K"); 227 | // v5 = ((unsigned __int64 (__cdecl *)(N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K *, SEL))objc_msgSend)( 228 | // v3, 229 | // "platform"); 230 | 231 | unsigned long long v12 = [self platform]; 232 | return CHSuper1(N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K, ODU2M2Y2Y2EzZmU4ZWZkZDJmYzA3MzAwYzEyZmM2MzcgIC0K, arg1); 233 | } 234 | 235 | //add new property 236 | //CHPropertyRetainNonatomic(TTTInstallIDPostDataHttpRequestSerializer, NSString*, newProperty, setNewProperty); 237 | CHPropertyRetainNonatomic(CustomViewController, NSString*, newProperty, setNewProperty); 238 | 239 | CHConstructor{ 240 | // CHLoadLateClass(CustomViewController); 241 | // CHLoadLateClass(TTDefaultHTTPRequestSerializer); 242 | // CHLoadLateClass(TTTInstallIDPostDataHttpRequestSerializer); 243 | // CHLoadLateClass(NSData); 244 | // CHLoadLateClass(NSMutableDictionary); 245 | CHLoadLateClass(IESAntiSpam); 246 | CHLoadLateClass(AWESecurityLaunchTask); 247 | // CHLoadLateClass(N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K); 248 | // CHLoadLateClass(TTInstallOpenUDID); 249 | //CHLoadLateClass(AWELocationService); 250 | 251 | // CHClassHook0(TTDefaultHTTPRequestSerializer, serializer); 252 | // CHClassHook0(TTTInstallIDPostDataHttpRequestSerializer, serializer); 253 | // //CHClassHook5(class, name1, name2, name3, name4, name5) CHHook_(class, name1 ## $ ## name2 ## $ ## name3 ## $ ## name4 ## $ ## name5 ## $) 254 | // CHClassHook5(TTTInstallIDPostDataHttpRequestSerializer, URLRequestWithURL, params, method, constructingBodyBlock, commonParams); 255 | // CHClassHook0(CustomViewController, getMyName); 256 | // CHClassHook0(CustomViewController, classMethod); 257 | // CHClassHook2(NSData, dataWithBytesNoCopy, length); 258 | // CHClassHook2(NSMutableDictionary, setObject, forKeyedSubscript); 259 | CHClassHook2(IESAntiSpam, encryptDataWithTimeStamp, parameters); 260 | CHClassHook1(AWESecurityLaunchTask, awes_showAppStoreDownloadAlert); 261 | // CHClassHook2(IESAntiSpam, encryptURLWithURL, formData); 262 | // CHClassHook1(N2ZlMDU0MThkYTEwYTcwNzM4NDViOWNiZTE2ZTQwMGQgIC0K, ODU2M2Y2Y2EzZmU4ZWZkZDJmYzA3MzAwYzEyZmM2MzcgIC0K); 263 | // CHClassHook0(TTInstallOpenUDID, _getOpenUDID); 264 | // CHClassHook1(TTInstallOpenUDID, valueWithError); 265 | //CHClassHook1(AWELocationService, base64StringWithDictionary); 266 | // 267 | // 268 | // CHHook0(CustomViewController, newProperty); 269 | // CHHook1(CustomViewController, setNewProperty); 270 | 271 | //CHHook0(TTTInstallIDPostDataHttpRequestSerializer, URLRequestWithURL); 272 | } 273 | 274 | --------------------------------------------------------------------------------