我正在创建一个模拟 VPN(实际上并没有创建到服务器的真实连接)以获取所有传入和传出的网络字节(信息)。
现在我可以获取数据包并解析它们。我得到的例子:
IP 版本:4 header 长度:20 总长度:60 协议(protocol):6 来源IP:10.0.2.0 目的IP:5.20.5.59 主机名:clients4.google.com
我想知道我应该做什么以及如何连接到网站/应用程序(目前无法连接)。
在此网站中:http://www.thegeekstuff.com/2014/06/android-vpn-service/写道需要执行以下步骤:
在第 2 步,我从数据包中获取信息。但是不要不明白应该如何进一步完成。也许有人可以详细解释我。另外,当我有它的 IP 地址时,也许可以告诉我如何获取目的地端口。还有代码:
public class VPN extends VpnService implements Handler.Callback, Runnable {
private static final String TAG = "VpnService";
private String mServerAddress = "127.0.0.1";
private int mServerPort = 55555;
private Handler mHandler;
private Thread mThread;
private ParcelFileDescriptor mInterface;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (mHandler == null) {
mHandler = new Handler(this);
}
if (mThread != null) {
mThread.interrupt();
}
mThread = new Thread(this, "VpnThread");
mThread.start();
return START_STICKY;
}
@Override
public void onDestroy() {
if (mThread != null) {
mThread.interrupt();
}
super.onDestroy();
}
@Override
public boolean handleMessage(Message message) {
if (message != null) {
Toast.makeText(this, (String) message.obj, Toast.LENGTH_SHORT).show();
}
return true;
}
@Override
public synchronized void run() {
try {
Log.i(TAG, "Starting");
InetSocketAddress server = new InetSocketAddress(mServerAddress, mServerPort);
run(server);
} catch (Exception e) {
Log.e(TAG, "Got " + e.toString());
try {
mInterface.close();
} catch (Exception e2) { }
Message msgObj = mHandler.obtainMessage();
msgObj.obj = "Disconnected";
mHandler.sendMessage(msgObj);
} finally {
}
}
DatagramChannel mTunnel = null;
protected boolean run(InetSocketAddress server) throws Exception {
boolean connected = false;
mTunnel = DatagramChannel.open();
if (!protect(mTunnel.socket())) {
throw new IllegalStateException("Cannot protect the tunnel");
}
mTunnel.connect(server);
mTunnel.configureBlocking(false);
handshake();
connected = true;
Message msgObj = mHandler.obtainMessage();
msgObj.obj = "Connected";
mHandler.sendMessage(msgObj);
new Thread ()
{
public void run ()
{
FileInputStream in = new FileInputStream(mInterface.getFileDescriptor());
ByteBuffer packet = ByteBuffer.allocate(32767);
DatagramChannel tunnel = mTunnel;
FileOutputStream out = new FileOutputStream(mInterface.getFileDescriptor());
int length;
String destIP;
try
{
while (true)
{
while ((length = in.read(packet.array())) > 0) {
packet.limit(length);
Log.d(TAG, "Total Length:" + mTunnel.socket().getInetAddress());
mTunnel.write(packet);
packet.flip();
TCP_IP TCP_debug = new TCP_IP(packet);
TCP_debug.debug();
destIP = TCP_debug.getDestination();
// InetAddress address = InetAddress.getByName(destIP);
// System.out.println(address.getHostAddress()); // Gaunamas IP (185.11.24.36)
// System.out.println(address.getHostName()); // www.15min.lt
out.write(packet.array(), 0, length);
packet.clear();
Thread.sleep(100);
}
}
}
catch (IOException e)
{
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
return connected;
}
private void makeConnection(String destination, int port) {
try {
run(new InetSocketAddress(destination, port));
}
catch (Exception e) {
Log.d(TAG, "klaida jungiantis");
}
}
private void handshake() throws Exception {
if (mInterface == null)
{
Builder builder = new Builder();
//builder.setMtu(1500);
//builder.addAddress("10.0.2.0", 32);
// builder.addRoute("0.0.0.0", 0);
builder.addAddress("192.168.0.1", 24);
builder.addDnsServer("8.8.8.8");
builder.addRoute("0.0.0.0", 0);
try {
mInterface.close();
} catch (Exception e) {
// ignore
}
mInterface = builder.setSession("VPN'as").establish();
}
}
}
public class TCP_IP extends VPN {
private ByteBuffer packet;
private String hostname;
private String destIP;
private String sourceIP;
private int version;
private int protocol;
private int port;
public TCP_IP(ByteBuffer pack) {
this.packet = pack;
}
public void debug() {
int buffer = packet.get();
int headerlength;
int temp;
version = buffer >> 4;
headerlength = buffer & 0x0F;
headerlength *= 4;
System.out.println("IP Version:"+version);
System.out.println("Header Length:"+headerlength);
String status = "";
status += "Header Length:"+headerlength;
buffer = packet.get(); //DSCP + EN
buffer = packet.getChar(); //Total Length
System.out.println( "Total Length:"+buffer);
buffer = packet.getChar(); //Identification
buffer = packet.getChar(); //Flags + Fragment Offset
buffer = packet.get(); //Time to Live
buffer = packet.get(); //Protocol
protocol = buffer;
System.out.println( "Protocol:"+buffer);
status += " Protocol:"+buffer;
buffer = packet.getChar(); //Header checksum
byte buff = (byte)buffer;
sourceIP = "";
buff = packet.get(); //Source IP 1st Octet
temp = ((int) buff) & 0xFF;
sourceIP += temp;
sourceIP += ".";
buff = packet.get(); //Source IP 2nd Octet
temp = ((int) buff) & 0xFF;
sourceIP += temp;
sourceIP += ".";
buff = packet.get(); //Source IP 3rd Octet
temp = ((int) buff) & 0xFF;
sourceIP += temp;
sourceIP += ".";
buff = packet.get(); //Source IP 4th Octet
temp = ((int) buff) & 0xFF;
sourceIP += temp;
System.out.println( "Source IP:"+sourceIP);
status += " Source IP:"+sourceIP;
destIP = "";
buff = packet.get(); //Destination IP 1st Octet
temp = ((int) buff) & 0xFF;
destIP += temp;
destIP += ".";
buff = packet.get(); //Destination IP 2nd Octet
temp = ((int) buff) & 0xFF;
destIP += temp;
destIP += ".";
buff = packet.get(); //Destination IP 3rd Octet
temp = ((int) buff) & 0xFF;
destIP += temp;
destIP += ".";
buff = packet.get(); //Destination IP 4th Octet
temp = ((int) buff) & 0xFF;
destIP += temp;
System.out.println( "Destination IP:" + destIP);
status += " Destination IP:"+destIP;
}
public String getDestination() {
return destIP;
}
public int getProtocol() {
return protocol;
}
public int getPort() {
return port;
}
public String getHostname() {
return hostname;
}
public int getIPversion() { return version; }
}
最佳答案
改变
private String mServerAddress = "127.0.0.1";
到
private String mServerAddress = "10.0.0.1";
我不知道答案并解释发生了什么,但我在 Android Monitor 中看到我们不能使用 localhost (127.0.0.1) 进入服务器地址。
还有另一个问题,SSL over HTTP (HTTPS)。如果您连接到类似 http://www.gorio.com.br 的网站它会起作用,但如果你尝试 https://www.google.com不会工作。
关于java - VPN数据包旁路,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24980097/
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
有时我需要处理键/值数据。我不喜欢使用数组,因为它们在大小上没有限制(很容易不小心添加超过2个项目,而且您最终需要稍后验证大小)。此外,0和1的索引变成了魔数(MagicNumber),并且在传达含义方面做得很差(“当我说0时,我的意思是head...”)。散列也不合适,因为可能会不小心添加额外的条目。我写了下面的类来解决这个问题:classPairattr_accessor:head,:taildefinitialize(h,t)@head,@tail=h,tendend它工作得很好并且解决了问题,但我很想知道:Ruby标准库是否已经带有这样一个类? 最佳
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
我正在尝试使用Curbgem执行以下POST以解析云curl-XPOST\-H"X-Parse-Application-Id:PARSE_APP_ID"\-H"X-Parse-REST-API-Key:PARSE_API_KEY"\-H"Content-Type:image/jpeg"\--data-binary'@myPicture.jpg'\https://api.parse.com/1/files/pic.jpg用这个:curl=Curl::Easy.new("https://api.parse.com/1/files/lion.jpg")curl.multipart_form_
无论您是想搭建桌面端、WEB端或者移动端APP应用,HOOPSPlatform组件都可以为您提供弹性的3D集成架构,同时,由工业领域3D技术专家组成的HOOPS技术团队也能为您提供技术支持服务。如果您的客户期望有一种在多个平台(桌面/WEB/APP,而且某些客户端是“瘦”客户端)快速、方便地将数据接入到3D应用系统的解决方案,并且当访问数据时,在各个平台上的性能和用户体验保持一致,HOOPSPlatform将帮助您完成。利用HOOPSPlatform,您可以开发在任何环境下的3D基础应用架构。HOOPSPlatform可以帮您打造3D创新型产品,HOOPSSDK包含的技术有:快速且准确的CAD
本教程将在Unity3D中混合Optitrack与数据手套的数据流,在人体运动的基础上,添加双手手指部分的运动。双手手背的角度仍由Optitrack提供,数据手套提供双手手指的角度。 01 客户端软件分别安装MotiveBody与MotionVenus并校准人体与数据手套。MotiveBodyMotionVenus数据手套使用、校准流程参照:https://gitee.com/foheart_1/foheart-h1-data-summary.git02 数据转发打开MotiveBody软件的Streaming,开始向Unity3D广播数据;MotionVenus中设置->选项选择Unit
文章目录一、概述简介原理模块二、配置Mysql使用版本环境要求1.操作系统2.mysql要求三、配置canal-server离线下载在线下载上传解压修改配置单机配置集群配置分库分表配置1.修改全局配置2.实例配置垂直分库水平分库3.修改group-instance.xml4.启动监听四、配置canal-adapter1修改启动配置2配置映射文件3启动ES数据同步查询所有订阅同步数据同步开关启动4.验证五、配置canal-admin一、概述简介canal是Alibaba旗下的一款开源项目,Java开发。基于数据库增量日志解析,提供增量数据订阅&消费。Git地址:https://github.co