Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A utillity program that takes ip addresses from input and transforms them into a linux command to drop them from iptables.
- #include <iostream>
- #include <cstring>
- using namespace std;
- class ipAddress{
- private:
- char ip[20];
- public:
- ipAddress(){
- strcpy(this->ip, "127.0.0");
- }
- ipAddress(char * ip){
- strcpy(this->ip, ip);
- }
- const char * getIpAddress(){
- return this->ip;
- }
- const void setIp(const char * ip){
- strcpy(this->ip, ip);
- }
- };
- int main(void){
- int n;
- cin >> n;
- ipAddress ips[n];
- for(int i=0; i<n; i++){
- char tmp[20];
- cin >> tmp;
- ips[i].setIp(tmp);
- }
- for(int i=0; i<n; i++)
- cout << "iptables -A INPUT -s " << ips[i].getIpAddress() << " -j DROP\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement