Skip to content

Instantly share code, notes, and snippets.

@wchen-r7
Created March 23, 2015 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wchen-r7/004d88d8abedf725d2ba to your computer and use it in GitHub Desktop.
Save wchen-r7/004d88d8abedf725d2ba to your computer and use it in GitHub Desktop.
<ruby>
def add_hosts
run_single("hosts -a -R 192.168.1.2-192.168.1.20")
Rex::Socket::RangeWalker.new("192.168.1.2-192.168.1.20").each do |ip|
id = framework.db.get_host(:address => ip).id
framework.db.hosts.update(id, :os_name => 'Microsoft Windows')
framework.db.hosts.update(id, :os_flavor => 'Windows 7')
framework.db.hosts.update(id, :os_sp => 'SP1')
end
run_single("hosts -R 192.168.1.2 -n Bob")
run_single("hosts -R 192.168.1.3 -n Alice")
run_single("hosts -R 192.168.1.4 -n John")
run_single("hosts -R 192.168.1.5 -n Miller")
run_single("hosts -R 192.168.1.6 -n Ken")
run_single("hosts -R 192.168.1.7 -n Tim")
run_single("hosts -R 192.168.1.8 -n Wayne")
run_single("hosts -R 192.168.1.9 -n Alex")
run_single("hosts -R 192.168.1.10 -n Diane")
run_single("hosts -R 192.168.1.11 -n Joe")
run_single("hosts -R 192.168.1.12 -n Chris")
run_single("hosts -R 192.168.1.13 -n Jane")
run_single("hosts -R 192.168.1.14 -n Kyle")
run_single("hosts -R 192.168.1.15 -n Nora")
run_single("hosts -R 192.168.1.16 -n Ann")
run_single("hosts -R 192.168.1.17 -n Kim")
run_single("hosts -R 192.168.1.18 -n Anderson")
run_single("hosts -R 192.168.1.19 -n William")
run_single("hosts -R 192.168.1.20 -n Sarah")
run_single("hosts -R 192.168.1.2-192.168.1.20 -t Sales")
run_single("hosts -R 192.168.1.2-192.168.1.5 -t Intern")
run_single("hosts -R 192.168.1.6-192.168.1.15 -t 'Account_Exec'")
run_single("hosts -R 192.168.1.16 -t 'Director_of_Sales'")
run_single("hosts -R 192.168.1.17-192.168.1.19 -t 'Regional_Manager'")
run_single("hosts -R 192.168.1.20 -t 'Senior_VP'")
end
['label_test_1', 'label_test_2'].each do |workspace|
run_single("workspace -a #{workspace}")
print_status("#{workspace} created")
run_single("workspace #{workspace}")
add_hosts
end
print_line
print_status("Use hosts -c 'address,name,os_name,os_flavor,os_sp,info,comments,tags'")
</ruby>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment