I want to write a little script for faster startup another program and also because I always mismatch the startup syntax. I have written the following script in C - I think i must not explain it. its just a few scans for the input and startup the script.
我想编写一个小脚本,以便更快地启动另一个程序,还因为我总是不匹配启动语法。我在C中编写了以下脚本 - 我想我不能解释它。只需几次扫描输入并启动脚本。
#include <stdio.h>
int main() {
char *RHOST[256];
char *ROUTER[256];
printf("Bitte IP des Router eingeben: ");
scanf("%s",&ROUTER);
printf("Bitte IP des Opfers eingeben: ");
scanf("%s",&RHOST);
//printf("Du willst über den Router %s die Pakete von %s spoofen?\n",ROUTER,RHOST);
system("gnome-terminal -x sh -c \"mitmf --spoof --arp -i wlan0 --target %s --gateway %s --inject --html-payload \"any useful stuff\"; cat\"", RHOST, ROUTER);
}
The problem is, when I want to start the script I get the following error
问题是,当我想启动脚本时,我收到以下错误
Traceback (most recent call last):
File "./mitmf.py", line 113, in <module>
p.initialize(args)
File "/usr/share/mitmf/plugins/Spoof.py", line 65, in initialize
self.routermac = getmacbyip(self.gateway)
File "/usr/lib/python2.7/dist-packages/scapy/layers/l2.py", line 53, in getmacbyip
tmp = map(ord, inet_aton(ip))
socket.error: illegal IP address string passed to inet_aton
I guess, I haven't formatted the ip address input correct, please can you show me how to do so? Thanks in advance
我猜,我没有格式化ip地址输入正确,请你告诉我怎么做?提前致谢
2 个解决方案
#1
1
The way you have RHOST
and ROUTER
declared are as arrays of pointers to char
, not arrays of char
which is probably what you want. They should instead be declared like this:
你声明RHOST和ROUTER的方式是作为char指针的数组,而不是char的数组,这可能是你想要的。它们应该像这样声明:
char RHOST[256];
char ROUTER[256];
And when calling scanf
, the %s
format string expects a char *
or char
array:
在调用scanf时,%s格式字符串需要char *或char数组:
scanf("%s",ROUTER);
Also, the system
function only takes a single parameter. It doesn't do printf
style substitutions. You should first assemble the command in a separate string using snprintf
, then pass that string to system
.
此外,系统功能仅采用单个参数。它不做printf样式替换。您应该首先使用snprintf在单独的字符串中组装命令,然后将该字符串传递给system。
char command[1000];
snprintf(command, 1000, "gnome-terminal -x sh -c \"mitmf --spoof --arp -i wlan0 --target %s --gateway %s --inject --html-payload \"any useful stuff\"; cat\"", RHOST, ROUTER);
system(command);
#2
1
You have made RHOST and ROUTER array of strings. Make them array of char. Note that you must not input more than 255 characters.
Also system takes a string as argument, you give 3 arguments. The last 2 will be ignored. You will have do one of two things. Either concat parts of the string in system() with RHOST and ROUTER or sprintf RHOST and ROUTER into string from system() and use it for the system() call.
你已经制作了RHOST和ROUTER字符串数组。使它们成为char数组。请注意,您输入的字符不得超过255个。系统还将字符串作为参数,您提供3个参数。最后2个将被忽略。你将做两件事之一。将system()中的字符串连接到RHOST和ROUTER,或者将sprintf RHOST和ROUTER连接到system()的字符串中,并将其用于system()调用。
#1
1
The way you have RHOST
and ROUTER
declared are as arrays of pointers to char
, not arrays of char
which is probably what you want. They should instead be declared like this:
你声明RHOST和ROUTER的方式是作为char指针的数组,而不是char的数组,这可能是你想要的。它们应该像这样声明:
char RHOST[256];
char ROUTER[256];
And when calling scanf
, the %s
format string expects a char *
or char
array:
在调用scanf时,%s格式字符串需要char *或char数组:
scanf("%s",ROUTER);
Also, the system
function only takes a single parameter. It doesn't do printf
style substitutions. You should first assemble the command in a separate string using snprintf
, then pass that string to system
.
此外,系统功能仅采用单个参数。它不做printf样式替换。您应该首先使用snprintf在单独的字符串中组装命令,然后将该字符串传递给system。
char command[1000];
snprintf(command, 1000, "gnome-terminal -x sh -c \"mitmf --spoof --arp -i wlan0 --target %s --gateway %s --inject --html-payload \"any useful stuff\"; cat\"", RHOST, ROUTER);
system(command);
#2
1
You have made RHOST and ROUTER array of strings. Make them array of char. Note that you must not input more than 255 characters.
Also system takes a string as argument, you give 3 arguments. The last 2 will be ignored. You will have do one of two things. Either concat parts of the string in system() with RHOST and ROUTER or sprintf RHOST and ROUTER into string from system() and use it for the system() call.
你已经制作了RHOST和ROUTER字符串数组。使它们成为char数组。请注意,您输入的字符不得超过255个。系统还将字符串作为参数,您提供3个参数。最后2个将被忽略。你将做两件事之一。将system()中的字符串连接到RHOST和ROUTER,或者将sprintf RHOST和ROUTER连接到system()的字符串中,并将其用于system()调用。