mirror of
https://github.com/hufrea/byedpi.git
synced 2025-01-19 09:11:53 +00:00
Send OOB data in first part
This commit is contained in:
parent
82e5229df0
commit
6b484d5988
53
desync.c
53
desync.c
@ -66,6 +66,18 @@ int setttl(int fd, int ttl, int family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
static inline void delay(long mk)
|
||||
{
|
||||
struct timespec time = {
|
||||
.tv_nsec = mk * 1000
|
||||
};
|
||||
nanosleep(&time, 0);
|
||||
}
|
||||
#else
|
||||
#define delay(mk) {}
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
int fake_attack(int sfd, char *buffer,
|
||||
size_t n, int cnt, int pos, int fa)
|
||||
@ -147,26 +159,39 @@ int disorder_attack(int sfd, char *buffer,
|
||||
int oob_attack(int sfd, char *buffer,
|
||||
ssize_t n, int pos, int fa)
|
||||
{
|
||||
struct packet pkt = oob_data;
|
||||
int size = oob_data.size;
|
||||
char *data = oob_data.data;
|
||||
|
||||
if (send(sfd, buffer, pos, 0) < 0) {
|
||||
uniperror("send");
|
||||
return -1;
|
||||
if (pos < n && size) {
|
||||
char rchar = buffer[pos];
|
||||
buffer[pos] = data[0];
|
||||
|
||||
if (send(sfd, buffer, pos + 1, MSG_OOB) < 0) {
|
||||
uniperror("send");
|
||||
buffer[pos] = rchar;
|
||||
return -1;
|
||||
}
|
||||
buffer[pos] = rchar;
|
||||
size--;
|
||||
data++;
|
||||
if (size) {
|
||||
delay(params.sfdelay);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < pkt.size; i++) {
|
||||
if (send(sfd, pkt.data + i, 1, MSG_OOB) < 0) {
|
||||
else {
|
||||
if (send(sfd, buffer, pos, 0) < 0) {
|
||||
uniperror("send");
|
||||
return -1;
|
||||
}
|
||||
#ifndef _WIN32
|
||||
if (pkt.size == 1) {
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (send(sfd, data + i, 1, MSG_OOB) < 0) {
|
||||
uniperror("send");
|
||||
return -1;
|
||||
}
|
||||
if (size != 1) {
|
||||
delay(params.sfdelay);
|
||||
}
|
||||
struct timespec delay = {
|
||||
.tv_nsec = params.sfdelay * 1000
|
||||
};
|
||||
nanosleep(&delay, 0);
|
||||
#endif
|
||||
}
|
||||
if (send(sfd, buffer + pos, n - pos, 0) < 0) {
|
||||
uniperror("send");
|
||||
|
5
main.c
5
main.c
@ -428,8 +428,9 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'w': //
|
||||
params.sfdelay = strtoul(optarg, &end, 0);
|
||||
if (optarg == end || params.sfdelay > 1000000 || *end)
|
||||
params.sfdelay = strtol(optarg, &end, 0);
|
||||
if (params.sfdelay < 0 || optarg == end
|
||||
|| params.sfdelay >= 1000000 || *end)
|
||||
invalid = 1;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user