为什么我的代码会取消注释掉这部分代码

时间:2016-04-26 17:54:34

标签: c string escaping

所以我一直用Wget和用户代理制作一个简单的HTTP flooder,但是在洪水泛滥时我意识到这种情况发生了

125.27.78.172 - - [26/Apr/2016:12:38:45 -0500] "GET / HTTP/1.1" 403 4961 "-" "Wget"

如果你对这个错误感到困惑,我会让我的朋友充斥我的VPS并发生这种情况

208.67.1.176 - - [26/Apr/2016:12:48:32 -0500] "GET / HTTP/1.0" 403 4961 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36"

为什么它不能与我合作代码:

sprintf(command, "wget -O /tmp/fff --header="Accept: text/html" --user-agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36" http://208.67.1.176/ ");

如果你想知道这是一个flooder,主代码会循环它

1 个答案:

答案 0 :(得分:3)

逃离字符串?

public interface Myinterface {
public void save(PolicyData p);
}

public class Product implements Myinterface{
public void save(PolicyData p){
    //logic here
}


public class Controller {


    private static HashMap<String,Myinterface> map=new HashMap<String,Myinterface>();

    public Controller(){
        map.put("Product", new Product());
        map.put("Limit", new Limit());
        map.put("Coverage", new Coverage());
    }

    public void save(PolicyData p,String item){
    Myinterface m=map.get(item);
    m.save(p);
    }
}
    }