Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519347
  • 博文数量: 184
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1172
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-21 13:40
个人简介

技术改变命运

文章分类

全部博文(184)

文章存档

2020年(16)

2017年(12)

2016年(156)

我的朋友

分类: Android平台

2020-10-08 09:23:04

 在 的文章中,对TCP/IP相关的网络编程进行了介绍。在 对文件描述符、输入输出流进行了介绍。本篇文章集于此介绍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.

代码示例

  1. function frida_Java() {
  2. Java.perform(function () {
  3. var ip_family = new Object();
  4. ip_family.family = "ipv4";
  5. ip_family.host = "47.92.90.25";
  6. ip_family.port = 7000;
  7. var socket = Socket.connect(ip_family);
  8. socket.then(function(successMessage){
  9. console.log(successMessage instanceof SocketConnection);
  10. successMessage.setNoDelay(true);
  11. var promise = successMessage.input.read(1000);
  12. promise.then(function(result){
  13. console.log(' burning'+hexdump(result,{lenght:1000}));
  14. }).catch(function(error){
  15. console.log(' fail:'+error);
  16. });
  17. });

运行结果如下,可以看出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相关内容,欢迎关注我的微信公众号:无情剑客。

在这里插入图片描述

阅读(1979) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~