Frida API之網絡

2020-10-08 無情劍客Burning

@[toc] 在聊天系統開發(1) 的文章中,對TCP/IP相關的網絡編程進行了介紹。在Frida API進階-文件 對文件描述符、輸入輸出流進行了介紹。本篇文章集於此介紹Frida中網絡相關的API。

Socket

Socket.listen([options]): open a TCP or UNIX listening socket. Returns a Promise that receives a SocketListener. Defaults to listening on both IPv4 and IPv6, if supported, and binding on all interfaces on a randomly selected TCP port.

Socket.connect(options): connect to a TCP or UNIX server. Returns a Promise that receives a SocketConnection.

Socket.type(handle): inspect the OS socket handle and return its type as a string which is either tcp, udp, tcp6, udp6, unix:stream, unix:dgram, or null if invalid or unknown.

Socket.localAddress(handle), Socket.peerAddress(handle): inspect the OS socket handle and return its local or peer address, or null if invalid or unknown. The object returned has the fields:

  • ip: (IP sockets) IP address as a string.
  • port: (IP sockets) IP port as a number.
  • path: (UNIX sockets) UNIX path as a string.

SocketListener

All methods are fully asynchronous and return Promise objects.

  • path: (UNIX family) path being listened on.
  • port: (IP family) IP port being listened on.
  • close(): close the listener, releasing resources related to it. Once the listener is closed, all other operations will fail. Closing a listener multiple times is allowed and will not result in an error.
  • accept(): wait for the next client to connect. The returned Promise receives a SocketConnection.

SocketConnection

Inherits from IOStream. All methods are fully asynchronous and return Promise objects.

  • setNoDelay(noDelay): disable the Nagle algorithm if noDelay is true, otherwise enable it. The Nagle algorithm is enabled by default, so it is only necessary to call this method if you wish to optimize for low delay instead of high throughput.

代碼示例

function frida_Java() { Java.perform(function () { var ip_family = new Object(); ip_family.family = "ipv4"; ip_family.host = "47.92.90.25"; ip_family.port = 7000; var socket = Socket.connect(ip_family); socket.then(function(successMessage){ console.log(successMessage instanceof SocketConnection); successMessage.setNoDelay(true); var promise = successMessage.input.read(1000); promise.then(function(result){ console.log(' burning'+hexdump(result,{lenght:1000})); }).catch(function(error){ console.log(' fail:'+error); }); });

運行結果如下,可以看出successMessage的類型是SocketConnection。

Nagle algorithm

在發出去的數據還沒有被確認之前,假如又有小數據生成,那麼就把小數據收集起來,湊滿一個MSS或者等收到確認後再發送。

JavaScript判斷數據類型

instanceof 是用來判斷 A 是否為 B 的實例,表達式為:A instanceof B,如果 A 是 B 的實例,則返回 true,否則返回 false。 在這裡需要特別注意的是:instanceof 檢測的是原型。

由上圖可以看出[]的原型指向Array.prototype,間接指向Object.prototype, 因此 [] instanceof Array 返回true, [] instanceof Object 也返回true。

其他的判斷方式

  1. typeof
  2. toString Object.prototype.toString.call(window);//[object global] window 是全局對象 global 的引用
  3. constructor

公眾號

更多Frida相關內容,歡迎關注我的微信公眾號:無情劍客。


相關焦點

  • Frida進階-API
    同時簡單介紹下HOOK 系統函數的利器frida-trace。內存,內存還是內存。>function frida_Java>function frida_JavaFrida-trace是一個動態跟蹤函數調用的工具,其強大之處在於能夠hook系統函數。
  • Frida API進階
    as a stringaddress: absolute address as a NativePointerslot: memory location where the import is stored, as a NativePointer //枚舉模塊中所有中的所有導入表(Import)函數 function frida_Module_import
  • Frida常用API
    instance.getName()); // bluetoothDeviceInfo(instance); }, onComplete: function() { console.log(&34;);} }); }); });通過下面的命令運行程序frida
  • Frida API的"樂器"
    運行上面的程序(在Win10系統下),使用腳本 frida-lObjC.api: an object mapping function names to NativeFunction instances for direct access to a big portion of
  • Frida腳本教程
    Hello worldHello world經典的入門程序,frida版本的來一個。frida -U -l hello.js com.android.bluetoothfrida -U -l hello.js com.android.bluetooth
  • 詳解Hook框架frida,讓你在逆向工作中效率成倍提升!
    4.Java Api在Hook開始之前,有必要對Java注入相關的api做一個簡單介紹, frida的注入腳本是JavaScript, 因此我們後面都是通過js腳本來操作設備上的Java代碼的。 2.搶紅包流程分析我們先來看一下,當我們點擊打開紅包之時發生了什麼呢? 下面是反編譯得到的打開紅包按鈕的點擊事件:
  • Frida之API使用進階
    運行 frida-U-l hello.js com.lingpao.lpcf622b–debug--runtime
  • 當Frida來「敲」門
    0x2 fridafrida是平臺原生app的Greasemonkey,說的專業一點,就是一種動態插樁工具,可以插入一些代碼到原生app的內存空間去,(動態地監視和修改其行為),這些原生平臺可以是Win、Mac、Linux、Android
  • frida學習筆記3 之hook so中的方法
    hook so 常用工具SubstrateCydia-需rootfrida--需rootVA系列-非root(VA、VXP、SandVXposed)frida方式hook材料準備heibaobao.apk
  • Frida全平臺使用
    pip install frida-tools網上狠毒文章說使用 pip install frida 和 pip install frida-tools 進行安裝,但是現在一條命名就夠了。如果不嫌麻煩,也可以通過源碼進行安裝。
  • 安卓安全從零到一: FRIDA hook Native基礎
    ");        // TCP掃描需要開網絡權限        // /root/Codes/AntiFrida/app/src/main/AndroidManifest.xml 添加 <uses-permission android:name="android.permission.INTERNET" />        // 只檢測開啟在[8000
  • Frida之文件操作
    import frida,sysdef on_message(message, data): if message[&39;] == &39;: print(&34;.format(message[&39;])) else: print(message)passsession = frida.get_usb_device
  • Frida使用之資料庫
    下面的代碼查詢buglydb資料庫信息:function frida_Java() { Java.perform(function () { var db, smt, row, id, tm; db = SqliteDatabase.open
  • Textobot-TB插件進程級API詳解&基礎篇完結
    如果是通過frida-gatget模塊注入又需要修改目標App,所以不管用哪種方式要持久化的執行JavaScript,在官方提供的接口裡面都沒有現成的。針對這個缺陷,Textobot用TB插件的模式彌補了Frida沒有持久化的問題。同時,為了方便編寫實用的TB插件,Textobot還導出了一些輔助性的C API。
  • 安卓逆向——Frida hook java層
    各位愛好安卓逆向的大佬們早上好,今天呢小弟不才在這裡拙劣的給大家講解一下咱們frida hook
  • Android逆向之手機環境配置
    這裡我以nexus 5 android 6.0.1為例,其他Google系手機型號及刷其他Android版本系統都是類似的);第二個則是安裝Android逆向分析hook框架(Xposed、frida)及一些常用的基礎插件等。
  • 小程序的api是什麼
    其實api並不專屬於小程序,任何程式語言或程序形態都有相對應的api。而我們今天談的小程序api,是微信小程序團隊為了方便開發人員製作開發小程序,而將一些常用的,或者底層的方法進行封裝,並提供給開發人員使用的程序接口。微信小程序是屬於相對封閉的一個環境,獲取或通知外部的程序,或者使用小程序內部的功能,都必須要經過小程序的api調用來實現。
  • 人臉識別的Face-api.js本地運行示例安裝
    face-api.js 是一個 JavaScript API,是基於 tensorflow.js 核心 API 的人臉檢測和人臉識別的瀏覽器實現。它實現了一系列的卷積神經網絡(CNN),針對網絡和行動裝置進行了優化。簡單好用。簡單地說,我們將首先定位輸入圖像中的所有人臉。
  • 順義驗證碼識別api_聚合數據
    順義驗證碼識別api,聚合數據,以大數據清洗、分析、挖掘等技術為主要技術手段,為企業客戶提供數據應用系統或定製化的數據分析成果,幫助企業進行經營決策。順義驗證碼識別api, 隨著卷積網絡的推廣,現在有各種各樣的快捷應用,例如識別驗證碼和數學公式等。
  • Restful API設計規範
    RESTFUL是一種網絡應用程式的設計風格和開發方式,基於HTTP,可以使用XML格式定義或JSON格式定義。RESTFUL適用於移動網際網路廠商作為業務使能接口的場景,實現第三方OTT調用行動網路資源的功能,動作類型為新增、變更、刪除所調用資源。