实现上网功能#278
Open
cdn2021 wants to merge 1 commit into
Open
Conversation
|
url参数存在命令注入 scanf确定没写错吗。。。 |
Author
|
命令注入.......................................... 懒得写转义 |
cdn2021
commented
Aug 12, 2021
Author
There was a problem hiding this comment.
修改后版本(我不是很会用Pull requests功能,就把修改后的代码贴在留言区了)
#include <stdio.h> // printf,scanf 原型
#include <stdlib.h> // malloc,free 原型
#include <string.h> //strcat原型
int surf_internet() {
while(1){
printf("URL:");
char * url = malloc(sizeof(char) * 1024); //1024个字符的url,应该够用了
if (scanf("%s",url)){
//读取
char * command = malloc(sizeof(char) * 1029);
*command = "curl ";
strcat(command,url);//拼接
system(command);//命令行调用
free(command); //释放内存
printf("\n");
};
free(url);
return 0;
}
OkAndGreat
approved these changes
Oct 6, 2021
rzhangbq
approved these changes
Oct 29, 2022
lingbopro
approved these changes
Nov 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
实现上网功能