Send OOB data in first part

This commit is contained in:
ruti 2024-03-01 18:00:25 +03:00
parent 82e5229df0
commit 6b484d5988
3 changed files with 43 additions and 17 deletions

View File

@ -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
View File

@ -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;

View File

@ -18,7 +18,7 @@ struct params {
char de_known;
int ttl;
int split;
size_t sfdelay;
long sfdelay;
enum demode attack;
char split_host;
int def_ttl;