Advertisement
Guest User

Untitled

a guest
May 28th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. SshClient sshClient = new SshClient(host, 22, login, password);
  2.  
  3. sshClient.Connect();
  4.  
  5. /*1 этап
  6. shellStream.WriteLine("yum install httpd");
  7. System.Threading.Thread.Sleep(1000 * 4);
  8. shellStream.WriteLine("y");
  9. shellStream.Expect(new Regex(@"Complete!"), new TimeSpan(0, 15, 0));*/
  10.  
  11. //2 этап
  12. var cmd = sshClient.CreateCommand("chkconfig iptables off && service iptables stop");
  13. cmd.Execute();
  14. cmd = sshClient.CreateCommand("chkconfig ip6tables off && service ip6tables stop");
  15. cmd.Execute();
  16.  
  17. //3 этап
  18. cmd = sshClient.CreateCommand("echo 'NETWORKING_IPV6=yes' >> /etc/sysconfig/network");
  19. cmd.Execute();
  20.  
  21. //4 этап
  22. cmd = sshClient.CreateCommand("echo"+" "+ "> /etc/sysconfig/network-scripts/ifcfg-sit1");
  23. cmd.Execute();
  24. cmd = sshClient.CreateCommand("echo 'DEVICE=sit1' >> /etc/sysconfig/network-scripts/ifcfg-sit1");
  25. cmd.Execute();
  26. cmd = sshClient.CreateCommand("echo 'BOOTPROTO=none' >> /etc/sysconfig/network-scripts/ifcfg-sit1");
  27. cmd.Execute();
  28. cmd = sshClient.CreateCommand("echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-sit1");
  29. cmd.Execute();
  30. cmd = sshClient.CreateCommand("echo 'IPV6INIT=yes' >> /etc/sysconfig/network-scripts/ifcfg-sit1");
  31. cmd.Execute();
  32. cmd = sshClient.CreateCommand("echo IPV6TUNNELIPV4="+REMOTE_IPV4+">> /etc/sysconfig/network-scripts/ifcfg-sit1");
  33. cmd.Execute();
  34. cmd = sshClient.CreateCommand("echo IPV6TUNNELIPV4LOCAL="+LOCAL_IPV4+">> /etc/sysconfig/network-scripts/ifcfg-sit1");
  35. cmd.Execute();
  36. cmd = sshClient.CreateCommand("echo IPV6ADDR="+LOCAL_IPV6+"::2/48"+">> /etc/sysconfig/network-scripts/ifcfg-sit1");
  37. cmd.Execute();
  38.  
  39. //5 этап
  40. cmd = sshClient.CreateCommand("echo sit1 ::/0 > /etc/sysconfig/static-routes-ipv6");
  41. cmd.Execute();
  42.  
  43. //6 этап
  44. cmd = sshClient.CreateCommand("echo -A INPUT -p 41 -j ACCEPT >> /etc/sysconfig/iptables");
  45. cmd.Execute();
  46.  
  47. //7 этап
  48. cmd = sshClient.CreateCommand("echo nameserver 2001:4860:4860::8888 >> /etc/resolv.conf");
  49. cmd.Execute();
  50. cmd = sshClient.CreateCommand("echo nameserver 2001:4860:4860::8844 >> /etc/resolv.conf");
  51. cmd.Execute();
  52.  
  53. //8 этап
  54. cmd = sshClient.CreateCommand("wget http://3proxy.ru/0.8.6/3proxy-0.8.6.tgz");
  55. System.Threading.Thread.Sleep(1000 * 8);
  56. cmd.Execute();
  57. cmd = sshClient.CreateCommand("tar -xvf 3proxy-0.8.6.tgz");
  58. cmd.Execute();
  59. System.Threading.Thread.Sleep(1000 * 8);
  60. cmd = sshClient.CreateCommand("cd 3proxy");
  61. cmd.Execute();
  62. cmd = sshClient.CreateCommand("ln -s /usr/lib64/libcrypto.so.10 /usr/lib/libcrypto.so");
  63. cmd.Execute();
  64. System.Threading.Thread.Sleep(1000 * 1);
  65. cmd = sshClient.CreateCommand("ln -s /usr/lib64/libssl.so.10 /usr/lib/libssl.so");
  66. cmd.Execute();
  67. System.Threading.Thread.Sleep(1000 * 1);
  68.  
  69. //9 этап
  70.  
  71. IDictionary<Renci.SshNet.Common.TerminalModes, uint> termkvp = new Dictionary<Renci.SshNet.Common.TerminalModes, uint>();
  72. termkvp.Add(Renci.SshNet.Common.TerminalModes.ECHO, 53);
  73. ShellStream shellStream = sshClient.CreateShellStream("xterm", 80,24, 800, 600, 1024, termkvp);
  74.  
  75. shellStream.WriteLine("make -f /root/3proxy/Makefile.Linux");
  76. System.Threading.Thread.Sleep(1000 * 50);
  77.  
  78.  
  79. //12 этап
  80.  
  81.  
  82. sshClient.Disconnect();
  83.  
  84. return "ok";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement