wibrfake-brk 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +48 -0
- data/.gitattributes +19 -0
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/ci.yml +90 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/Dockerfile +69 -0
- data/Gemfile +68 -0
- data/README.md +188 -0
- data/Rakefile +6 -0
- data/app/assets/config/manifest.js +5 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/2024-12-30-07:58:34-screenshot.png +0 -0
- data/app/assets/images/facebook/facebook-logo.svg +3 -0
- data/app/assets/images/google/googlelogo_color_272x92dp.png +0 -0
- data/app/assets/images/instagram/app-store.png +0 -0
- data/app/assets/images/instagram/google-play.png +0 -0
- data/app/assets/images/instagram/instagram-logo.png +0 -0
- data/app/assets/images/instagram/screenshot1.png +0 -0
- data/app/assets/images/instagram/screenshot2.png +0 -0
- data/app/assets/images/instagram/screenshot3.png +0 -0
- data/app/assets/images/instagram/screenshot4.png +0 -0
- data/app/assets/images/nauta_etecsa/CUBADEBATE.jpg +0 -0
- data/app/assets/images/nauta_etecsa/CUBAEDUCA.jpg +0 -0
- data/app/assets/images/nauta_etecsa/CUBARTE.jpg +0 -0
- data/app/assets/images/nauta_etecsa/CUBASI.jpg +0 -0
- data/app/assets/images/nauta_etecsa/ECURED.jpg +0 -0
- data/app/assets/images/nauta_etecsa/OFERTAS.jpg +0 -0
- data/app/assets/images/nauta_etecsa/PAPELETA.jpg +0 -0
- data/app/assets/images/nauta_etecsa/contenedor_bg.jpg +0 -0
- data/app/assets/images/nauta_etecsa/etecsa.jpg +0 -0
- data/app/assets/images/nauta_etecsa/nauta_wifi.jpg +0 -0
- data/app/assets/images/nauta_hogar/CUBADEBATE.jpg +0 -0
- data/app/assets/images/nauta_hogar/CUBAEDUCA.jpg +0 -0
- data/app/assets/images/nauta_hogar/CUBARTE.jpg +0 -0
- data/app/assets/images/nauta_hogar/CUBASI.jpg +0 -0
- data/app/assets/images/nauta_hogar/ECURED.jpg +0 -0
- data/app/assets/images/nauta_hogar/OFERTAS.jpg +0 -0
- data/app/assets/images/nauta_hogar/PAPELETA.jpg +0 -0
- data/app/assets/images/nauta_hogar/banner_hogar.png +0 -0
- data/app/assets/images/wibrfake/Breaker-Wallpaper1.jpg +0 -0
- data/app/assets/images/wibrfake/mac-list-parameter.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-100x100.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-32x32.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-48x48.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-apfake-on.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-apfake-set-basic.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-apfake-show.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-help.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-hostpot.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-init.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-init2.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-login-basic.jpg +0 -0
- data/app/assets/images/wibrfake/wibrfake-mac-list.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-mac-ramset-oui.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-mac-ramset.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-mac-set.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-mac-show.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-need-signin.jpg +0 -0
- data/app/assets/images/wibrfake/wibrfake-session-active.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-session-init.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-session-list.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-session-new.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-session-rename.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-session-save.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-web-server-apfake.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-web-server-on.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-web-server-show.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-wkdump-loaded.png +0 -0
- data/app/assets/images/wibrfake/wibrfake-wkdump.png +0 -0
- data/app/assets/images/wibrfake/wibrfake.png +0 -0
- data/app/assets/stylesheets/application.css +15 -0
- data/app/assets/stylesheets/basic/page_basic.css +0 -0
- data/app/assets/stylesheets/facebook/page_facebook.css +93 -0
- data/app/assets/stylesheets/google/page_google.css +137 -0
- data/app/assets/stylesheets/instagram/page_instagram.css +94 -0
- data/app/assets/stylesheets/nauta_etecsa/page_nauta.css +325 -0
- data/app/assets/stylesheets/nauta_hogar/page_nauta.css +469 -0
- data/app/assets/stylesheets/wibrfake/page_wibrfake.css +1181 -0
- data/app/assets/stylesheets/wibrfake/page_wibrfake_about.css +486 -0
- data/app/channels/application_cable/channel.rb +4 -0
- data/app/channels/application_cable/connection.rb +4 -0
- data/app/controllers/application_controller.rb +15 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/sessions_controller.rb +111 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/sessions_helper.rb +2 -0
- data/app/javascript/application.js +3 -0
- data/app/javascript/bootstrap.bundle.min.js +7 -0
- data/app/javascript/controllers/application.js +9 -0
- data/app/javascript/controllers/hello_controller.js +7 -0
- data/app/javascript/controllers/index.js +4 -0
- data/app/javascript/google/page_google.js +50 -0
- data/app/javascript/incorrect3.js +29 -0
- data/app/javascript/page_wibrfake.js +50 -0
- data/app/javascript/page_wibrfake_about.js +147 -0
- data/app/jobs/application_job.rb +7 -0
- data/app/mailers/application_mailer.rb +4 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/user.rb +6 -0
- data/app/views/layouts/application.html.erb +33 -0
- data/app/views/layouts/mailer.html.erb +13 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/pwa/manifest.json.erb +22 -0
- data/app/views/pwa/service-worker.js +26 -0
- data/app/views/sessions/basic/basic.html.erb +21 -0
- data/app/views/sessions/facebook/facebook.html.erb +132 -0
- data/app/views/sessions/google/google.html.erb +72 -0
- data/app/views/sessions/index.html.erb +11 -0
- data/app/views/sessions/instagram/instagram.html.erb +69 -0
- data/app/views/sessions/nauta_etecsa/nauta_etecsa.html.erb +97 -0
- data/app/views/sessions/nauta_hogar/nauta_hogar.html.erb +135 -0
- data/app/views/sessions/wibrfake/about/about.html.erb +164 -0
- data/app/views/sessions/wibrfake/wibrfake.html.erb +417 -0
- data/bin/.names.rb.swp +0 -0
- data/bin/brakeman +7 -0
- data/bin/bundle +114 -0
- data/bin/docker-entrypoint +13 -0
- data/bin/google.wkdump +3 -0
- data/bin/importmap +4 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/rubocop +8 -0
- data/bin/setup +37 -0
- data/bin/wibrfake +20 -0
- data/config/application.rb +26 -0
- data/config/boot.rb +4 -0
- data/config/cable.yml +10 -0
- data/config/credentials.yml.enc +1 -0
- data/config/database.yml +16 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +85 -0
- data/config/environments/production.rb +105 -0
- data/config/environments/test.rb +67 -0
- data/config/icons/application-x-wkdump.xml +13 -0
- data/config/icons/hicolor/16x16/mimetypes/application-x-wkdump.png +0 -0
- data/config/icons/hicolor/32x32/mimetypes/application-x-wkdump.png +0 -0
- data/config/icons/hicolor/48x48/mimetypes/application-x-wkdump.png +0 -0
- data/config/icons/hicolor/icon-theme.cache +0 -0
- data/config/icons/hicolor/index.theme +20 -0
- data/config/icons/wkdump.desktop +5 -0
- data/config/importmap.rb +7 -0
- data/config/initializers/assets.rb +12 -0
- data/config/initializers/content_security_policy.rb +25 -0
- data/config/initializers/devise.rb +313 -0
- data/config/initializers/filter_parameter_logging.rb +8 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/permissions_policy.rb +13 -0
- data/config/locales/devise.en.yml +65 -0
- data/config/locales/en.yml +31 -0
- data/config/puma.rb +35 -0
- data/config/routes.rb +12 -0
- data/config/storage.yml +34 -0
- data/config.ru +6 -0
- data/db/development.sqlite3 +0 -0
- data/db/schema.rb +14 -0
- data/ext/wibrfake/extconf.rb +3 -0
- data/ext/wibrfake/wibrfake.h +0 -0
- data/images/ouilist.png +0 -0
- data/images/wibrfakehelp.png +0 -0
- data/images/wibrfakeinit.png +0 -0
- data/lib/assets/.keep +0 -0
- data/lib/tasks/.keep +0 -0
- data/lib/wibrfake/Config/ipaddr.rb +71 -0
- data/lib/wibrfake/Config/options.rb +98 -0
- data/lib/wibrfake/Config/security_wpa.rb +43 -0
- data/lib/wibrfake/DataBase/howuis.db +0 -0
- data/lib/wibrfake/DataBase/ouis.db +0 -0
- data/lib/wibrfake/DataBase/ouis.rb +24 -0
- data/lib/wibrfake/DataBase/rename.rb +15 -0
- data/lib/wibrfake/DataBase/show.rb +18 -0
- data/lib/wibrfake/Dnsmasq/dhcp.rb +149 -0
- data/lib/wibrfake/Dnsmasq/dhcp_prueba.rb +135 -0
- data/lib/wibrfake/Dnsmasq/dns.rb +34 -0
- data/lib/wibrfake/Dnsmasq/dns_prueba.rb +36 -0
- data/lib/wibrfake/Dnsmasq/dnsmasq.rb +33 -0
- data/lib/wibrfake/Listing/apfake.rb +28 -0
- data/lib/wibrfake/Listing/clients.rb +76 -0
- data/lib/wibrfake/Listing/ouis.rb +53 -0
- data/lib/wibrfake/Listing/process.rb +14 -0
- data/lib/wibrfake/Listing/sessions.rb +47 -0
- data/lib/wibrfake/Listing/web_server.rb +17 -0
- data/lib/wibrfake/Listing/wireless.rb +30 -0
- data/lib/wibrfake/Logs/credentials.log +59 -0
- data/lib/wibrfake/NetworkInterface/ip-routing.rb +99 -0
- data/lib/wibrfake/NetworkInterface/mac.rb +114 -0
- data/lib/wibrfake/NetworkInterface/monitor.rb +44 -0
- data/lib/wibrfake/NetworkInterface/ouis.db +0 -0
- data/lib/wibrfake/Process/id.rb +11 -0
- data/lib/wibrfake/Process/pids.log +5 -0
- data/lib/wibrfake/Process/pkill.rb +124 -0
- data/lib/wibrfake/Process/processes.rb +76 -0
- data/lib/wibrfake/Rails/login.rb +20 -0
- data/lib/wibrfake/Rails/routes.rb +76 -0
- data/lib/wibrfake/Rails/service.rb +58 -0
- data/lib/wibrfake/Rails/service_usage.rb +46 -0
- data/lib/wibrfake/Sessions/session.rb +188 -0
- data/lib/wibrfake/String/string.rb +109 -0
- data/lib/wibrfake/Tmp/config.yml +1 -0
- data/lib/wibrfake/config.rb +24 -0
- data/lib/wibrfake/help.rb +107 -0
- data/lib/wibrfake/optionpr.rb +68 -0
- data/lib/wibrfake/run.rb +9 -0
- data/lib/wibrfake/ty/apld.rb +110 -0
- data/lib/wibrfake/ty/prompt/answers_collector.rb +78 -0
- data/lib/wibrfake/ty/prompt/block_paginator.rb +59 -0
- data/lib/wibrfake/ty/prompt/choice.rb +147 -0
- data/lib/wibrfake/ty/prompt/choices.rb +129 -0
- data/lib/wibrfake/ty/prompt/confirm_question.rb +158 -0
- data/lib/wibrfake/ty/prompt/const.rb +17 -0
- data/lib/wibrfake/ty/prompt/converter_dsl.rb +21 -0
- data/lib/wibrfake/ty/prompt/converter_registry.rb +69 -0
- data/lib/wibrfake/ty/prompt/converters.rb +182 -0
- data/lib/wibrfake/ty/prompt/distance.rb +49 -0
- data/lib/wibrfake/ty/prompt/enum_list.rb +433 -0
- data/lib/wibrfake/ty/prompt/errors.rb +31 -0
- data/lib/wibrfake/ty/prompt/evaluator.rb +29 -0
- data/lib/wibrfake/ty/prompt/expander.rb +321 -0
- data/lib/wibrfake/ty/prompt/keypress.rb +98 -0
- data/lib/wibrfake/ty/prompt/list.rb +589 -0
- data/lib/wibrfake/ty/prompt/mask_question.rb +96 -0
- data/lib/wibrfake/ty/prompt/multi_list.rb +224 -0
- data/lib/wibrfake/ty/prompt/multiline.rb +72 -0
- data/lib/wibrfake/ty/prompt/paginator.rb +111 -0
- data/lib/wibrfake/ty/prompt/question/checks.rb +105 -0
- data/lib/wibrfake/ty/prompt/question/modifier.rb +96 -0
- data/lib/wibrfake/ty/prompt/question/validation.rb +72 -0
- data/lib/wibrfake/ty/prompt/question.rb +391 -0
- data/lib/wibrfake/ty/prompt/result.rb +42 -0
- data/lib/wibrfake/ty/prompt/selected_choices.rb +77 -0
- data/lib/wibrfake/ty/prompt/slider.rb +286 -0
- data/lib/wibrfake/ty/prompt/statement.rb +55 -0
- data/lib/wibrfake/ty/prompt/suggestion.rb +113 -0
- data/lib/wibrfake/ty/prompt/symbols.rb +89 -0
- data/lib/wibrfake/ty/prompt/test.rb +36 -0
- data/lib/wibrfake/ty/prompt/timer.rb +75 -0
- data/lib/wibrfake/ty/prompt/utils.rb +42 -0
- data/lib/wibrfake/ty/prompt/version.rb +7 -0
- data/lib/wibrfake/ty/prompt.rb +589 -0
- data/lib/wibrfake/version.rb +5 -0
- data/lib/wibrfake/wibrfake_cli.rb +683 -0
- data/log/.keep +0 -0
- data/pruebas/daemon1.pid +1 -0
- data/pruebas/daemon2.pid +1 -0
- data/pruebas/daemons.rb +44 -0
- data/public/404.html +67 -0
- data/public/406-unsupported-browser.html +66 -0
- data/public/422.html +67 -0
- data/public/500.html +66 -0
- data/public/icon.png +0 -0
- data/public/icon.svg +3 -0
- data/public/robots.txt +1 -0
- data/storage/.keep +0 -0
- data/test/application_system_test_case.rb +5 -0
- data/test/channels/application_cable/connection_test.rb +13 -0
- data/test/controllers/.keep +0 -0
- data/test/controllers/sessions_controller_test.rb +7 -0
- data/test/fixtures/files/.keep +0 -0
- data/test/fixtures/users.yml +11 -0
- data/test/helpers/.keep +0 -0
- data/test/integration/.keep +0 -0
- data/test/mailers/.keep +0 -0
- data/test/models/.keep +0 -0
- data/test/models/user_test.rb +7 -0
- data/test/system/.keep +0 -0
- data/test/test_helper.rb +15 -0
- data/tmp/.keep +0 -0
- data/tmp/pids/.keep +0 -0
- data/tmp/storage/.keep +0 -0
- data/vendor/.keep +0 -0
- data/vendor/javascript/.keep +0 -0
- data/wibrfake.gemspec +49 -0
- metadata +743 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
require_relative 'processes'
|
2
|
+
module WibrFake
|
3
|
+
class Pkill
|
4
|
+
def self.kill(process_name)
|
5
|
+
status = false
|
6
|
+
pids = WibrFake::Processes.status(process_name)
|
7
|
+
if(pids.length>1)
|
8
|
+
pids.each{|pid|
|
9
|
+
puts "Process #{process_name} with PID #{pid} found"
|
10
|
+
}
|
11
|
+
puts "Select the process to kill or press [ENTER] to kill all:"
|
12
|
+
input = gets.chomp
|
13
|
+
if(input.to_i>0) and (pids.include?(input))
|
14
|
+
puts "Killing #{process_name} with PID: #{input.to_i}"
|
15
|
+
begin
|
16
|
+
Process.kill("TERM", input.to_i)
|
17
|
+
WibrFake::Processes.del(input)
|
18
|
+
rescue Errno::ESRCH
|
19
|
+
WibrFake::Processes.del(input)
|
20
|
+
end
|
21
|
+
puts "Killed #{process_name}"
|
22
|
+
elsif (input=="")
|
23
|
+
pids.each{|pid|
|
24
|
+
puts "Killing #{process_name} with PID: #{pid}"
|
25
|
+
begin
|
26
|
+
Process.kill("TERM", pid.to_i)
|
27
|
+
WibrFake::Processes.del(pid)
|
28
|
+
rescue Errno::ESRCH
|
29
|
+
WibrFake::Processes.del(pid)
|
30
|
+
end
|
31
|
+
puts "Killed #{process_name} with PID: #{pid}"
|
32
|
+
}
|
33
|
+
end
|
34
|
+
elsif(pids.length==1)
|
35
|
+
puts "Killing #{process_name} with PID: #{pids[0]}"
|
36
|
+
begin
|
37
|
+
Process.kill("TERM", pids[0].to_i)
|
38
|
+
WibrFake::Processes.del(pids[0])
|
39
|
+
rescue Errno::ESRCH
|
40
|
+
WibrFake::Processes.del(pids[0])
|
41
|
+
end
|
42
|
+
sleep(1)
|
43
|
+
puts "process killed #{process_name}"
|
44
|
+
status = true
|
45
|
+
end
|
46
|
+
return status
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.kill_all()
|
50
|
+
processes_name = %w[hostapd wpa_supplicant web_server dns dhcp]
|
51
|
+
processes_name.each{|process_name|
|
52
|
+
pids = WibrFake::Processes.status(process_name)
|
53
|
+
if(pids.length>1)
|
54
|
+
pids.each{|pid|
|
55
|
+
puts "Process #{process_name} with PID #{pid} found"
|
56
|
+
}
|
57
|
+
puts "Select the process to kill or press [ENTER] to kill all:"
|
58
|
+
input = gets.chomp
|
59
|
+
if(input.to_i>0) and (pids.include?(input))
|
60
|
+
puts "Killing #{process_name} with PID: #{input.to_i}"
|
61
|
+
begin
|
62
|
+
Process.kill("TERM", input.to_i)
|
63
|
+
WibrFake::Processes.del(input)
|
64
|
+
rescue Errno::ESRCH
|
65
|
+
WibrFake::Processes.del(input)
|
66
|
+
end
|
67
|
+
puts "Killed #{process_name}"
|
68
|
+
elsif (input=="")
|
69
|
+
pids.each{|pid|
|
70
|
+
puts "Killing #{process_name} with PID: #{pid}"
|
71
|
+
begin
|
72
|
+
Process.kill("TERM", pid.to_i)
|
73
|
+
WibrFake::Processes.del(pid)
|
74
|
+
rescue Errno::ESRCH
|
75
|
+
WibrFake::Processes.del(pid)
|
76
|
+
end
|
77
|
+
puts "Killed #{process_name} with PID: #{pid}"
|
78
|
+
}
|
79
|
+
end
|
80
|
+
elsif(pids.length==1)
|
81
|
+
puts "Killing #{process_name} with PID: #{pids[0]}"
|
82
|
+
begin
|
83
|
+
Process.kill("TERM", pids[0].to_i)
|
84
|
+
WibrFake::Processes.del(pids[0].to_i)
|
85
|
+
rescue Errno::ESRCH
|
86
|
+
WibrFake::Processes.del(pids[0].to_i)
|
87
|
+
end
|
88
|
+
sleep(1)
|
89
|
+
puts "process killed #{process_name}"
|
90
|
+
status = true
|
91
|
+
end
|
92
|
+
}
|
93
|
+
end
|
94
|
+
def self.kill_silence(process_name)
|
95
|
+
pids = WibrFake::Processes.status(process_name)
|
96
|
+
if(pids.length>=1)
|
97
|
+
pids.each{|pid|
|
98
|
+
begin
|
99
|
+
Process.kill("TERM", pid.to_i)
|
100
|
+
WibrFake::Processes.del(pid.to_i)
|
101
|
+
rescue Errno::ESRCH
|
102
|
+
WibrFake::Processes.del(pid)
|
103
|
+
end
|
104
|
+
}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
def self.kill_all_silence()
|
108
|
+
processes_name = %w[hostapd wpa_supplicant web_server dns dhcp]
|
109
|
+
processes_name.each{|process_name|
|
110
|
+
pids = WibrFake::Processes.status(process_name)
|
111
|
+
if(pids.length>=1)
|
112
|
+
pids.each{|pid|
|
113
|
+
begin
|
114
|
+
Process.kill("TERM", pid)
|
115
|
+
WibrFake::Processes.del(pid)
|
116
|
+
rescue Errno::ESRCH
|
117
|
+
WibrFake::Processes.del(pid)
|
118
|
+
end
|
119
|
+
}
|
120
|
+
end
|
121
|
+
}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module WibrFake
|
2
|
+
class Processes
|
3
|
+
def initialize
|
4
|
+
processes = ['wibrfake_hostapd', 'wibrfake_dns', 'wibrfake_dhcp']
|
5
|
+
processes.each{|process|
|
6
|
+
status_proc(process).each{|pid|
|
7
|
+
if(!pid.empty?)
|
8
|
+
set(process.split('_')[1], pid)
|
9
|
+
end
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
def self.status(process, verb=0)
|
14
|
+
pids = []
|
15
|
+
File.foreach(File.join(File.dirname(__FILE__), 'pids.log')){|file|
|
16
|
+
if(file.include?(process))
|
17
|
+
[file].each{|line|
|
18
|
+
line.split("\n").each{|pid|
|
19
|
+
pids << pid.split[1]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
if(pids.empty?)
|
26
|
+
return "\033[38;5;196moff\e[1;37m" if(verb==1)
|
27
|
+
[]
|
28
|
+
else
|
29
|
+
return "\033[38;5;46mon\e[1;37m" if(verb==1)
|
30
|
+
return pids
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.status_proc(process)
|
35
|
+
pids = Array.new
|
36
|
+
Dir.entries('/proc').each do |entry|
|
37
|
+
next unless entry =~ /^\d+$/ # Solo directorios numéricos (PIDs)
|
38
|
+
comm_path = File.join('/proc', entry, 'comm')
|
39
|
+
begin
|
40
|
+
cmdline = File.read(comm_path).strip
|
41
|
+
if cmdline.include?(process)
|
42
|
+
pids << entry.to_i
|
43
|
+
end
|
44
|
+
rescue Errno::ENOENT, Errno::EACCES
|
45
|
+
next
|
46
|
+
end
|
47
|
+
end
|
48
|
+
return pids
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.status_all
|
52
|
+
process = []
|
53
|
+
File.foreach(File.join(File.dirname(__FILE__), 'pids.log')){|line|
|
54
|
+
process << line if(!line.strip.empty?)
|
55
|
+
}
|
56
|
+
process
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.set(process_name, pid)
|
60
|
+
File.open(File.join(File.dirname(__FILE__), 'pids.log'), 'a'){|file|
|
61
|
+
file.write "\n#{process_name}: #{pid}"
|
62
|
+
}
|
63
|
+
[process_name, pid]
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.del(pid)
|
67
|
+
File.open(File.join(File.dirname(__FILE__), 'pids.log'), 'r+'){|file|
|
68
|
+
lines = file.readlines
|
69
|
+
lines.reject!{|line| line.include?(pid.to_s)}
|
70
|
+
file.rewind
|
71
|
+
file.write(lines.join)
|
72
|
+
file.truncate(file.pos)
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module WibrFake
|
2
|
+
class RailsLogin
|
3
|
+
def self.logins
|
4
|
+
return ['basic', 'nauta_etecsa', 'nauta_hogar', 'facebook', 'instagram', 'google']
|
5
|
+
end
|
6
|
+
def self.validate?(login)
|
7
|
+
logins.each{|log_in|
|
8
|
+
if(log_in==login)
|
9
|
+
return true
|
10
|
+
end
|
11
|
+
}
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.show(verb = 0)
|
16
|
+
return logins if verb==0
|
17
|
+
puts logins
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module WibrFake
|
2
|
+
class Rails
|
3
|
+
def self.usage(route: nil)
|
4
|
+
routes = {
|
5
|
+
route: route,
|
6
|
+
route_about: "#{route}/about",
|
7
|
+
sessions_get: "sessions#wibrfake",
|
8
|
+
sessions_get_about: "sessions#wibrfake_about",
|
9
|
+
}
|
10
|
+
end
|
11
|
+
def self.routes(login: nil, route: nil)
|
12
|
+
case login
|
13
|
+
when 'basic'
|
14
|
+
routes = [{sessions_get: "sessions#basic", as_get: :page_index}]
|
15
|
+
routes << {
|
16
|
+
route_generate_204: 'generate_204/',
|
17
|
+
route_login: route,
|
18
|
+
sessions_get: "sessions#basic",
|
19
|
+
sessions_post: "sessions#basic_login",
|
20
|
+
as_get: "basic_login",
|
21
|
+
as_post: "basic_login_post"
|
22
|
+
}
|
23
|
+
when 'nauta_etecsa'
|
24
|
+
routes = [{sessions_get: "sessions#nauta_etecsa", as_get: :page_index}]
|
25
|
+
routes << {
|
26
|
+
route_generate_204: 'generate_204/',
|
27
|
+
route_login: route,
|
28
|
+
sessions_get: "sessions#nauta_etecsa",
|
29
|
+
sessions_post: "sessions#nauta_etecsa_login",
|
30
|
+
as_get: "nauta_etecsa_login",
|
31
|
+
as_post: "nauta_etecsa_login_post"
|
32
|
+
}
|
33
|
+
when 'nauta_hogar'
|
34
|
+
routes = [{sessions_get: "sessions#nauta_hogar", as_get: :page_index}]
|
35
|
+
routes << {
|
36
|
+
route_generate_204: 'generate_204/',
|
37
|
+
route_login: route,
|
38
|
+
sessions_get: "sessions#nauta_hogar",
|
39
|
+
sessions_post: "sessions#nauta_hogar_login",
|
40
|
+
as_get: "nauta_hogar_login",
|
41
|
+
as_post: "nauta_hogar_login_post"
|
42
|
+
}
|
43
|
+
when 'facebook'
|
44
|
+
routes = [{sessions_get: "sessions#facebook", as_get: :page_index}]
|
45
|
+
routes << {
|
46
|
+
route_generate_204: 'generate_204/',
|
47
|
+
route_login: route,
|
48
|
+
sessions_get: "sessions#facebook",
|
49
|
+
sessions_post: "sessions#facebook_login",
|
50
|
+
as_get: "facebook_login",
|
51
|
+
as_post: "facebook_login_post"
|
52
|
+
}
|
53
|
+
when 'instagram'
|
54
|
+
routes = [{sessions_get: "sessions#instagram", as_get: :page_index}]
|
55
|
+
routes << {
|
56
|
+
route_generate_204: 'generate_204/',
|
57
|
+
route_login: route,
|
58
|
+
sessions_get: "sessions#instagram",
|
59
|
+
sessions_post: "sessions#instagram_login",
|
60
|
+
as_get: "instagram_login",
|
61
|
+
as_post: "instagram_login_post"
|
62
|
+
}
|
63
|
+
when 'google'
|
64
|
+
routes = [{sessions_get: "sessions#google", as_get: :page_index}]
|
65
|
+
routes << {
|
66
|
+
route_generate_204: 'generate_204/',
|
67
|
+
route_login: route,
|
68
|
+
sessions_get: "sessions#google",
|
69
|
+
sessions_post: "sessions#google_login",
|
70
|
+
as_get: "google_login",
|
71
|
+
as_post: "google_login_post"
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module WibrFake
|
2
|
+
class Rails
|
3
|
+
def initialize(host, port, login, route, credential_route, iface, id)
|
4
|
+
begin
|
5
|
+
require 'puma'
|
6
|
+
require_relative '../Rails/routes'
|
7
|
+
require_relative '../../../config/environment'
|
8
|
+
rescue LoadError => e
|
9
|
+
puts "Error al cargar una libreria"
|
10
|
+
puts e.message
|
11
|
+
exit(1)
|
12
|
+
end
|
13
|
+
@host = host
|
14
|
+
@port = port
|
15
|
+
@login = login
|
16
|
+
@route = route
|
17
|
+
ENV['IFACE'] = iface
|
18
|
+
ENV['ID'] = id
|
19
|
+
ENV['CREDENTIAL_ROUTE'] = credential_route
|
20
|
+
end
|
21
|
+
def start
|
22
|
+
status = true
|
23
|
+
begin
|
24
|
+
server_pid = fork {
|
25
|
+
begin
|
26
|
+
route_root, route_login = WibrFake::Rails.routes(login: @login, route: @route)
|
27
|
+
::Rails.application.routes.clear!
|
28
|
+
|
29
|
+
::Rails.application.routes.draw {
|
30
|
+
devise_for :users
|
31
|
+
if(route_login[:route]=='/')
|
32
|
+
root to: route_root[:sessions_get], as: route_root[:as_get]
|
33
|
+
else
|
34
|
+
get route_login[:route_login], to: route_login[:sessions_get]
|
35
|
+
|
36
|
+
end
|
37
|
+
get route_login[:route_generate_204], to: route_login[:sessions_get], as: route_login[:as_get]
|
38
|
+
post route_login[:route_generate_204], to: route_login[:sessions_post], as: route_login[:as_post]
|
39
|
+
}
|
40
|
+
Puma::Server.new(::Rails.application).tap {|server|
|
41
|
+
server.add_tcp_listener @host, @port
|
42
|
+
}.run
|
43
|
+
WibrFake::Processes.set("web_server", Process.pid)
|
44
|
+
sleep
|
45
|
+
rescue Errno::EADDRINUSE
|
46
|
+
warn "\n\r\e[1;33m[\e[1;37m!\e[1;33m]\e[1;37m There is already a captive portal web service running on port #{@port}. Run 'pkill web_server' to terminate the web server or set a new port with 'set port [PORT]'."
|
47
|
+
puts "\n"
|
48
|
+
print "\r\033[38;5;236m\e[0m\033[48;5;236m \033[38;5;196mwibrfake #{@iface} \e[0m\033[38;5;236m\e[0m "
|
49
|
+
end
|
50
|
+
}
|
51
|
+
|
52
|
+
rescue => e
|
53
|
+
puts e.message
|
54
|
+
end
|
55
|
+
return {"#{server_pid}_#{@login}" => "http://#{@host}:#{@port}/#{@route}"}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module WibrFake
|
2
|
+
class RailsUsage
|
3
|
+
def initialize
|
4
|
+
begin
|
5
|
+
require 'puma'
|
6
|
+
require_relative '../Rails/routes'
|
7
|
+
require_relative '../../../config/environment'
|
8
|
+
rescue LoadError => e
|
9
|
+
puts "Error al cargar una libreria"
|
10
|
+
puts e.message
|
11
|
+
exit(1)
|
12
|
+
end
|
13
|
+
@host = '0.0.0.0'
|
14
|
+
@port = 1972
|
15
|
+
@route = 'wibrfake/'
|
16
|
+
end
|
17
|
+
def start
|
18
|
+
begin
|
19
|
+
#server_pid = fork {
|
20
|
+
routes = WibrFake::Rails.usage(route: @route)
|
21
|
+
::Rails.application.routes.clear!
|
22
|
+
|
23
|
+
::Rails.application.routes.draw {
|
24
|
+
devise_for :users
|
25
|
+
get routes[:route], to: routes[:sessions_get]
|
26
|
+
get routes[:route_about], to: routes[:sessions_get_about]
|
27
|
+
}
|
28
|
+
Puma::Server.new(::Rails.application).tap {|server|
|
29
|
+
server.add_tcp_listener @host, @port
|
30
|
+
}.run
|
31
|
+
#}
|
32
|
+
#WibrFake::Processes.set("web_server", server_pid)
|
33
|
+
puts "\n\033[38;5;196m[\e[1;37m+\033[38;5;196m]\e[1;37m Wibrfake server to learn how to use it is mounted on:"
|
34
|
+
puts "http://#{@host}:#{@port.to_s}/#{@route}"
|
35
|
+
puts 'To exit use Ctrl + C'
|
36
|
+
sleep
|
37
|
+
rescue Interrupt
|
38
|
+
exit(0)
|
39
|
+
rescue => e
|
40
|
+
puts e.message
|
41
|
+
end
|
42
|
+
#return {"#{server_pid}_#{@login}" => "http://#{@host}:#{@port}/#{@route}"}
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
module WibrFake
|
2
|
+
class Session
|
3
|
+
def initialize(id: nil)
|
4
|
+
begin
|
5
|
+
require_relative '../Listing/sessions'
|
6
|
+
require_relative '../Config/ipaddr.rb'
|
7
|
+
|
8
|
+
@id = id
|
9
|
+
Dir.mkdir(File.join(File.dirname(__FILE__), '..', 'Tmp', @id))
|
10
|
+
config_session = {
|
11
|
+
'WibrFake' => 'Config',
|
12
|
+
'session' => {
|
13
|
+
'session_save' => false,
|
14
|
+
'session_modified' => false,
|
15
|
+
'name' => id
|
16
|
+
}
|
17
|
+
}
|
18
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'Tmp', id, 'config.yml'), 'w'){|file|
|
19
|
+
file.write(config_session.to_yaml)
|
20
|
+
}
|
21
|
+
rescue LoadError => e
|
22
|
+
puts e.message
|
23
|
+
rescue Errno::EINVAL
|
24
|
+
rescue Errno::EEXIST
|
25
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m Session: #{@id} already exists"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def rename(number: nil, name: nil, id: nil)
|
30
|
+
sessions = WibrFake::Listing.sessions_list_return
|
31
|
+
status = false
|
32
|
+
verify_session = false
|
33
|
+
if(sessions.empty?)
|
34
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m No active sessions"
|
35
|
+
else
|
36
|
+
sessions.each_with_index{|session, index|
|
37
|
+
index += 1
|
38
|
+
if(index==number.to_i)
|
39
|
+
begin
|
40
|
+
FileUtils.mv(File.join(File.dirname(__FILE__), '..', 'Tmp', session), File.join(File.dirname(__FILE__), '..', 'Tmp', name))
|
41
|
+
FileUtils.mv(File.join(File.dirname(__FILE__), '..', 'Tmp', name, 'wkdump', "#{session}.wkdump"), File.join(File.dirname(__FILE__), '..', 'Tmp', name, 'wkdump', "#{name}.wkdump"))
|
42
|
+
rescue Errno::EINVAL
|
43
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m The session name already exists"
|
44
|
+
end
|
45
|
+
verify_session = "current" if (session==id)
|
46
|
+
status = true
|
47
|
+
elsif(session==number)
|
48
|
+
begin
|
49
|
+
FileUtils.mv(File.join(File.dirname(__FILE__), '..', 'Tmp', session), File.join(File.dirname(__FILE__), '..', 'Tmp', name))
|
50
|
+
FileUtils.mv(File.join(File.dirname(__FILE__), '..', 'Tmp', name, 'wkdump', "#{session}.wkdump"), File.join(File.dirname(__FILE__), '..', 'Tmp', name, 'wkdump', "#{name}.wkdump"))
|
51
|
+
print "\033[38;5;46m[\e[1;37m+\033[38;5;46m]\e[1;37m Session [#{session}] was renamed to: #{name} "
|
52
|
+
puts
|
53
|
+
|
54
|
+
rescue Errno::EINVAL
|
55
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m The session name already exists"
|
56
|
+
end
|
57
|
+
verify_session = "current" if (session==id)
|
58
|
+
status = true
|
59
|
+
end
|
60
|
+
}
|
61
|
+
if(status)
|
62
|
+
if(verify_session=='current')
|
63
|
+
return verify_session
|
64
|
+
else
|
65
|
+
return name
|
66
|
+
end
|
67
|
+
else
|
68
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m The session index or name was not found"
|
69
|
+
return status
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
def remove(number: nil, id: nil)
|
74
|
+
status = false
|
75
|
+
eliminated = false
|
76
|
+
sessions = WibrFake::Listing.sessions_list_return
|
77
|
+
if(sessions.empty?)
|
78
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m The specified session does not exist"
|
79
|
+
else
|
80
|
+
sessions.each_with_index{|session, index|
|
81
|
+
index += 1
|
82
|
+
if(index==number.to_i)
|
83
|
+
if(id==session)
|
84
|
+
status = true
|
85
|
+
end
|
86
|
+
eliminated = true
|
87
|
+
FileUtils.rm_rf(File.join(File.dirname(__FILE__), '..', 'Tmp', session))
|
88
|
+
print "\033[38;5;46m[\e[1;37m+\033[38;5;46m]\e[1;37m Session: #{session} has been removed"
|
89
|
+
puts
|
90
|
+
elsif(session==number)
|
91
|
+
if(id==session)
|
92
|
+
status = true
|
93
|
+
end
|
94
|
+
eliminated = true
|
95
|
+
FileUtils.rm_rf(File.join(File.dirname(__FILE__), '..', 'Tmp', session))
|
96
|
+
print "\033[38;5;46m[\e[1;37m+\033[38;5;46m]\e[1;37m Session: #{session} has been removed"
|
97
|
+
puts
|
98
|
+
end
|
99
|
+
}
|
100
|
+
end
|
101
|
+
if(!eliminated)
|
102
|
+
warn "\n\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m The session '#{number}' does not exist"
|
103
|
+
end
|
104
|
+
return status
|
105
|
+
end
|
106
|
+
def active(id: nil)
|
107
|
+
if(id.nil?)
|
108
|
+
puts
|
109
|
+
else
|
110
|
+
config_session = {
|
111
|
+
'WibrFake' => 'Config',
|
112
|
+
'session' => {
|
113
|
+
'session_save' => true,
|
114
|
+
'session_modified' => false,
|
115
|
+
}
|
116
|
+
}
|
117
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'Tmp', id, 'config.yml'), 'w'){|file|
|
118
|
+
file.write(config_session.to_yaml)
|
119
|
+
}
|
120
|
+
warn "\033[38;5;46m[\e[1;37m+\033[38;5;46m]\e[1;37m Session settings activated and saved successfully"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
def save(id: nil)
|
124
|
+
config_yml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'Tmp', id, 'config.yml'))
|
125
|
+
if(id.nil?)
|
126
|
+
puts
|
127
|
+
else
|
128
|
+
config_session = {
|
129
|
+
'WibrFake' => 'Config',
|
130
|
+
'session' => {
|
131
|
+
'session_save' => config_yml['session']['session_save'],
|
132
|
+
'session_modified' => false,
|
133
|
+
}
|
134
|
+
}
|
135
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'Tmp', id, 'config.yml'), 'w'){|file|
|
136
|
+
file.write(config_session.to_yaml)
|
137
|
+
}
|
138
|
+
end
|
139
|
+
end
|
140
|
+
def init(number: nil)
|
141
|
+
status = false
|
142
|
+
workspace = String.new
|
143
|
+
sessions = WibrFake::Listing.sessions_list_return
|
144
|
+
if(sessions.empty?)
|
145
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m Session defined does not exist"
|
146
|
+
else
|
147
|
+
sessions.each_with_index{|session, index|
|
148
|
+
index += 1
|
149
|
+
if(index==number.to_i)
|
150
|
+
workspace = session
|
151
|
+
status = true
|
152
|
+
elsif(session==number)
|
153
|
+
workspace = session
|
154
|
+
status = true
|
155
|
+
end
|
156
|
+
}
|
157
|
+
if(status)
|
158
|
+
puts "\033[38;5;46m[\e[1;37m+\033[38;5;46m]\e[1;37m Initializing session: #{workspace}"
|
159
|
+
return workspace
|
160
|
+
else
|
161
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m The session index or name was not found"
|
162
|
+
return status
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
def session_modified(status: false, id: nil)
|
167
|
+
if(id.nil?)
|
168
|
+
warn "\e[1;33m[\e[1;37m+\e[1;33m]\e[1;37m Session ID not found"
|
169
|
+
else
|
170
|
+
#Load config.yml file
|
171
|
+
config_yml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'Tmp', id, 'config.yml'))
|
172
|
+
if(status)
|
173
|
+
config_session = {
|
174
|
+
'WibrFake' => 'Config',
|
175
|
+
'session' => {
|
176
|
+
'session_save' => config_yml['session']['session_save'],
|
177
|
+
'session_modified' => true,
|
178
|
+
'name' => config_yml['session']['name']
|
179
|
+
}
|
180
|
+
}
|
181
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'Tmp', id, 'config.yml'), 'w'){|file|
|
182
|
+
file.write(config_session.to_yaml)
|
183
|
+
}
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|