技术改变命运
分类: Android平台
2020-10-08 09:23:04
在 的文章中,对TCP/IP相关的网络编程进行了介绍。在 对文件描述符、输入输出流进行了介绍。本篇文章集于此介绍Frida中网络相关的API。
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:
All methods are fully asynchronous and return Promise objects.
Inherits from IOStream. All methods are fully asynchronous and return Promise objects.
- 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。
在发出去的数据还没有被确认之前,假如又有小数据生成,那么就把小数据收集起来,凑满一个MSS或者等收到确认后再发送。
instanceof 是用来判断 A 是否为 B 的实例,表达式为:A instanceof B,如果 A 是 B 的实例,则返回 true,否则返回 false。 在这里需要特别注意的是:instanceof 检测的是原型。 由上图可以看出[]的原型指向Array.prototype,间接指向Object.prototype, 因此 [] instanceof Array 返回true, [] instanceof Object 也返回true。
其他的判断方式
更多Frida相关内容,欢迎关注我的微信公众号:无情剑客。