Introduction
Introduction Statistics Contact Development Disclaimer Help
resetpw - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
git clone git://jay.scot/warvox
Log
Files
Refs
README
---
resetpw (2352B)
---
1 #!/usr/bin/env ruby
2
3 ENV['RAILS_ENV'] ||= 'production'
4
5 # bundler/setup just sets up the $LOAD_PATHs, the gems aren't automatica…
6 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile',File.dirname(__F…
7 require 'bundler/setup'
8
9 # rails/all must be required explicitly to get the railties that pro/ui/…
10 require 'rails/all'
11 # require all the gems in the current environment
12 Bundler.require(*Rails.groups(assets: %w(development test cucumber)))
13
14 APP_PATH = File.expand_path('../../config/application', __FILE__)
15 require File.expand_path('../../config/boot', __FILE__)
16 require APP_PATH
17 Rails.application.require_environment!
18
19 uname = ARGV.shift
20 upass = ARGV.shift
21
22 def generate_password
23 set = ( [*(0x21 .. 0x2f)] + [*(0x3a .. 0x3F)] + [*(0x5b .. 0x60)] + [*…
24 set << "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
25 str = ''
26 cnt = 0
27 while not (str.length >= 8 and str =~ /[A-Za-z]/ and str =~ /[0-9]/ an…
28 if str.length > 12
29 str = str[0,4]
30 next
31 end
32 str << set[ rand(set.length), 1]
33 cnt += 1
34 end
35 str
36 end
37
38
39 user = uname ? User.find_by_login(uname) : User.first
40 if uname and not user
41 $stderr.puts "[-] User #{uname} was not found"
42 exit(1)
43 end
44
45 if not user
46 $stderr.puts "[-] No user account has been created"
47 exit(1)
48 end
49
50 randpass = upass || generate_password()
51
52
53 $stdout.puts %Q|
54
55 ********************************
56 * *
57 * WarVOX Password Reset *
58 * *
59 ********************************
60
61 [*] Warning! This tool will reset the password for the '#{user.login}' u…
62 [*] To continue, please type "yes"
63
64 |
65
66 $stdout.write "Continue? (yes/no) > "
67 $stdout.flush
68
69 inp = $stdin.readline
70
71 if inp.strip.downcase != 'yes'
72 $stdout.puts "[*] Reset cancelled, hit enter to exit"
73 $stdin.readline
74 exit(0)
75 end
76
77
78 user.password = randpass
79 user.password_confirmation = randpass
80 user.save!
81
82 $stdout.puts %Q|
83 [*] The password for #{user.login} has been reset to a random value
84
85 New Password: #{randpass}
86
87 [*] Please change this password on the next login.
88 |
89
90 $stdout.puts "[*] Hit enter to exit"
91 $stdin.readline
92 exit(0)
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.