pwn 0.5.487 → 0.5.489
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 +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +3 -3
- data/lib/pwn/plugins/repl.rb +68 -53
- data/lib/pwn/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0bd30ef667258a8c6d6f5b2f64b7a5d39791b79b2f70e874c15ea2f846cfc543
|
|
4
|
+
data.tar.gz: 43d46bd61ce79485b22640c37ede4e67ac44462d8f03c31c6bdeae40433fcd49
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61f58c0a487e678a1a33c9df4f75b5bf5b5360845fb5ab9a16acaa629c678df17430e1d99c75a0d6c94126b3aa3711de1f4d247af22789aed073570fcb63e1d2
|
|
7
|
+
data.tar.gz: 1c46a44f7590948fe513e063836a9b82db47ba455e05e0fab7b47c2d19cf58b394dc337d92c5edeb247d280c70ed198fce385c6fb9b23408df8387653dbd5b4d
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
|
@@ -37,7 +37,7 @@ $ cd /opt/pwn
|
|
|
37
37
|
$ ./install.sh
|
|
38
38
|
$ ./install.sh ruby-gem
|
|
39
39
|
$ pwn
|
|
40
|
-
pwn[v0.5.
|
|
40
|
+
pwn[v0.5.489]:001 >>> PWN.help
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
[](https://youtu.be/G7iLUY4FzsI)
|
|
@@ -52,7 +52,7 @@ $ rvm use ruby-3.4.4@pwn
|
|
|
52
52
|
$ gem uninstall --all --executables pwn
|
|
53
53
|
$ gem install --verbose pwn
|
|
54
54
|
$ pwn
|
|
55
|
-
pwn[v0.5.
|
|
55
|
+
pwn[v0.5.489]:001 >>> PWN.help
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
If you're using a multi-user install of RVM do:
|
|
@@ -62,7 +62,7 @@ $ rvm use ruby-3.4.4@pwn
|
|
|
62
62
|
$ rvmsudo gem uninstall --all --executables pwn
|
|
63
63
|
$ rvmsudo gem install --verbose pwn
|
|
64
64
|
$ pwn
|
|
65
|
-
pwn[v0.5.
|
|
65
|
+
pwn[v0.5.489]:001 >>> PWN.help
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:
|
data/lib/pwn/plugins/repl.rb
CHANGED
|
@@ -432,7 +432,8 @@ module PWN
|
|
|
432
432
|
|
|
433
433
|
PWN.send(:remove_const, :MeshTxEchoThread) if PWN.const_defined?(:MeshTxEchoThread)
|
|
434
434
|
PWN.send(:remove_const, :MqttObj) if PWN.const_defined?(:MqttObj)
|
|
435
|
-
PWN.send(:remove_const, :
|
|
435
|
+
PWN.send(:remove_const, :MeshRxHeaderWin) if PWN.const_defined?(:MeshRxHeaderWin)
|
|
436
|
+
PWN.send(:remove_const, :MeshRxBodyWin) if PWN.const_defined?(:MeshRxBodyWin)
|
|
436
437
|
PWN.send(:remove_const, :MeshTxWin) if PWN.const_defined?(:MeshTxWin)
|
|
437
438
|
PWN.send(:remove_const, :MeshMutex) if PWN.const_defined?(:MeshMutex)
|
|
438
439
|
PWN.send(:remove_const, :MqttSubThread) if PWN.const_defined?(:MqttSubThread)
|
|
@@ -486,7 +487,7 @@ module PWN
|
|
|
486
487
|
Curses.init_pair(color_id, color_fg, color_bg)
|
|
487
488
|
end
|
|
488
489
|
PWN.const_set(:MeshColors, (1..mesh_highlight_colors.length).to_a)
|
|
489
|
-
PWN.const_set(:
|
|
490
|
+
PWN.const_set(:MeshLastColor, PWN::MeshColors.sample)
|
|
490
491
|
|
|
491
492
|
mesh_ui_colors = []
|
|
492
493
|
mesh_highlight_colors.each_with_index do |hl_hash, idx|
|
|
@@ -508,29 +509,37 @@ module PWN
|
|
|
508
509
|
white = mesh_ui_colors[6][:color_id]
|
|
509
510
|
|
|
510
511
|
rx_height = Curses.lines - 4
|
|
511
|
-
|
|
512
|
+
rx_header_win = Curses::Window.new(rx_height, Curses.cols, 0, 0)
|
|
512
513
|
# TODO: Scrollable but should stay below header_line
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
rx_header_win.scrollok(false)
|
|
515
|
+
rx_header_win.nodelay = true
|
|
516
|
+
rx_header_win.attron(Curses.color_pair(cyan) | Curses::A_BOLD)
|
|
516
517
|
|
|
517
518
|
# Make rx_header bold and green
|
|
518
|
-
|
|
519
|
+
rx_header_win.attron(Curses.color_pair(green) | Curses::A_BOLD)
|
|
519
520
|
rx_header = "<<< #{host}:#{port} | #{region}/#{topic} | ch:#{channel_num} >>>"
|
|
520
521
|
rx_header_len = rx_header.length
|
|
521
522
|
rx_header_pos = (Curses.cols / 2) - (rx_header_len / 2)
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
rx_header_win.setpos(1, rx_header_pos)
|
|
524
|
+
rx_header_win.addstr(rx_header)
|
|
525
|
+
rx_header_win.attroff(Curses.color_pair(green) | Curses::A_BOLD)
|
|
525
526
|
# Jump two lines below header before messages begin
|
|
526
|
-
|
|
527
|
-
|
|
527
|
+
rx_header_win.setpos(2, 0)
|
|
528
|
+
rx_header_win.attron(Curses.color_pair(cyan) | Curses::A_BOLD)
|
|
528
529
|
header_line = "\u2014" * Curses.cols
|
|
529
530
|
rx_header_bottom_line_pos = (Curses.cols / 2) - (header_line.length / 2)
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
531
|
+
rx_header_win.addstr(header_line)
|
|
532
|
+
rx_header_win.attroff(Curses.color_pair(cyan) | Curses::A_BOLD)
|
|
533
|
+
rx_header_win.refresh
|
|
534
|
+
PWN.const_set(:MeshRxHeaderWin, rx_header_win)
|
|
535
|
+
|
|
536
|
+
body_start_row = 3
|
|
537
|
+
body_height = rx_height - body_start_row
|
|
538
|
+
rx_body_win = Curses::Window.new(body_height, Curses.cols, body_start_row, 0)
|
|
539
|
+
rx_body_win.scrollok(true)
|
|
540
|
+
rx_body_win.nodelay = true
|
|
541
|
+
rx_body_win.refresh
|
|
542
|
+
PWN.const_set(:MeshRxBodyWin, rx_body_win)
|
|
534
543
|
|
|
535
544
|
tx_height = rx_height - 1
|
|
536
545
|
tx_win = Curses::Window.new(4, Curses.cols, tx_height, 0)
|
|
@@ -538,14 +547,13 @@ module PWN
|
|
|
538
547
|
tx_win.nodelay = true
|
|
539
548
|
tx_win.refresh
|
|
540
549
|
|
|
541
|
-
PWN.const_set(:MeshRxWin, rx_win)
|
|
542
550
|
PWN.const_set(:MeshTxWin, tx_win)
|
|
543
551
|
PWN.const_set(:MeshMutex, Mutex.new)
|
|
544
552
|
|
|
545
553
|
# Live typing echo thread (idempotent)
|
|
546
554
|
tx_prompt = "#{region}/#{topic} >>>"
|
|
547
555
|
echo_thread = Thread.new do
|
|
548
|
-
|
|
556
|
+
last_line = nil
|
|
549
557
|
loop do
|
|
550
558
|
break unless pi.config.pwn_mesh
|
|
551
559
|
|
|
@@ -558,7 +566,7 @@ module PWN
|
|
|
558
566
|
base_line = "#{prefix}#{msg_input}"
|
|
559
567
|
cursor_abs_index = prefix.length + cursor_pos
|
|
560
568
|
current_line = base_line
|
|
561
|
-
if
|
|
569
|
+
if last_line != current_line
|
|
562
570
|
mutex.synchronize do
|
|
563
571
|
tx_win.clear
|
|
564
572
|
tx_win.attron(Curses.color_pair(red) | Curses::A_BOLD)
|
|
@@ -593,9 +601,9 @@ module PWN
|
|
|
593
601
|
tx_win.attroff(Curses.color_pair(yellow) | Curses::A_BOLD)
|
|
594
602
|
tx_win.refresh
|
|
595
603
|
end
|
|
596
|
-
|
|
604
|
+
last_line = current_line
|
|
597
605
|
end
|
|
598
|
-
sleep 0.
|
|
606
|
+
sleep 0.00001
|
|
599
607
|
end
|
|
600
608
|
end
|
|
601
609
|
echo_thread.abort_on_exception = false
|
|
@@ -609,6 +617,7 @@ module PWN
|
|
|
609
617
|
detach: true
|
|
610
618
|
) do |_|
|
|
611
619
|
last_from = nil
|
|
620
|
+
last_line = nil
|
|
612
621
|
Meshtastic::MQTT.subscribe(
|
|
613
622
|
mqtt_obj: mqtt_obj,
|
|
614
623
|
region: region,
|
|
@@ -622,7 +631,7 @@ module PWN
|
|
|
622
631
|
decoded = packet[:decoded]
|
|
623
632
|
next unless decoded.key?(:portnum) && decoded[:portnum] == :TEXT_MESSAGE_APP
|
|
624
633
|
|
|
625
|
-
|
|
634
|
+
# rx_header_win = PWN.const_get(:MeshRxHeaderWin)
|
|
626
635
|
mutex = PWN.const_get(:MeshMutex)
|
|
627
636
|
|
|
628
637
|
from = "#{packet[:node_id_from]} ".ljust(9, ' ')
|
|
@@ -631,43 +640,43 @@ module PWN
|
|
|
631
640
|
rx_text = decoded[:payload]
|
|
632
641
|
ts = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
|
|
633
642
|
|
|
634
|
-
# Select a random color
|
|
643
|
+
# Select a random color different from the last used one
|
|
635
644
|
colors_arr = PWN.const_get(:MeshColors)
|
|
636
|
-
|
|
637
|
-
|
|
645
|
+
last_color = PWN.const_get(:MeshLastColor)
|
|
646
|
+
color = last_color
|
|
638
647
|
unless last_from == from
|
|
639
|
-
PWN.send(:remove_const, :
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
PWN.const_set(:
|
|
648
|
+
PWN.send(:remove_const, :MeshLastColor)
|
|
649
|
+
color_choices = colors_arr.reject { |c| c == last_color }
|
|
650
|
+
color = color_choices.sample
|
|
651
|
+
PWN.const_set(:MeshLastColor, color)
|
|
643
652
|
end
|
|
644
653
|
|
|
645
654
|
to_label = 'To'
|
|
646
655
|
to_label = 'DM' unless to == '!ffffffff'
|
|
647
656
|
current_line = "\nDate: #{ts}\nFrom: #{from}\n#{to_label}: #{to}\nTopic: #{absolute_topic}\n> #{rx_text}"
|
|
648
657
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
658
|
+
if last_line != current_line
|
|
659
|
+
rx_body_win = PWN.const_get(:MeshRxBodyWin)
|
|
660
|
+
mutex.synchronize do
|
|
661
|
+
inner_height = rx_body_win.maxy - 5
|
|
662
|
+
inner_width = rx_body_win.maxx
|
|
663
|
+
segments = current_line.scan(/.{1,#{inner_width}}/)
|
|
664
|
+
rx_body_win.attron(Curses.color_pair(color) | Curses::A_REVERSE)
|
|
665
|
+
segments.each do |seg|
|
|
666
|
+
rx_body_win.setpos(rx_body_win.cury, 0)
|
|
667
|
+
# Handle wide Unicode characters for proper alignment
|
|
668
|
+
display_width = Unicode::DisplayWidth.of(seg)
|
|
669
|
+
width_diff = seg.length - display_width
|
|
670
|
+
shift_width = inner_width + width_diff
|
|
671
|
+
line = seg.ljust(shift_width)
|
|
672
|
+
rx_body_win.addstr(line)
|
|
673
|
+
end
|
|
674
|
+
rx_body_win.attroff(Curses.color_pair(color) | Curses::A_REVERSE)
|
|
675
|
+
rx_body_win.refresh
|
|
665
676
|
end
|
|
666
|
-
|
|
677
|
+
last_line = current_line
|
|
678
|
+
last_from = from
|
|
667
679
|
end
|
|
668
|
-
rx_win.attroff(Curses.color_pair(pair) | Curses::A_REVERSE)
|
|
669
|
-
|
|
670
|
-
last_from = from
|
|
671
680
|
end
|
|
672
681
|
end
|
|
673
682
|
rescue StandardError => e
|
|
@@ -749,16 +758,22 @@ module PWN
|
|
|
749
758
|
PWN.send(:remove_const, :MqttObj)
|
|
750
759
|
end
|
|
751
760
|
|
|
752
|
-
if PWN.const_defined?(:
|
|
753
|
-
PWN.const_get(:
|
|
754
|
-
PWN.send(:remove_const, :
|
|
761
|
+
if PWN.const_defined?(:MeshRxHeaderWin)
|
|
762
|
+
PWN.const_get(:MeshRxHeaderWin).close
|
|
763
|
+
PWN.send(:remove_const, :MeshRxHeaderWin)
|
|
755
764
|
end
|
|
765
|
+
|
|
766
|
+
if PWN.const_defined?(:MeshRxBodyWin)
|
|
767
|
+
PWN.const_get(:MeshRxBodyWin).close
|
|
768
|
+
PWN.send(:remove_const, :MeshRxBodyWin)
|
|
769
|
+
end
|
|
770
|
+
|
|
756
771
|
if PWN.const_defined?(:MeshTxWin)
|
|
757
772
|
PWN.const_get(:MeshTxWin).close
|
|
758
773
|
PWN.send(:remove_const, :MeshTxWin)
|
|
759
774
|
end
|
|
760
775
|
PWN.send(:remove_const, :MeshColors) if PWN.const_defined?(:MeshColors)
|
|
761
|
-
PWN.send(:remove_const, :
|
|
776
|
+
PWN.send(:remove_const, :MeshLastColor) if PWN.const_defined?(:MeshLastColor)
|
|
762
777
|
PWN.send(:remove_const, :MeshMutex) if PWN.const_defined?(:MeshMutex)
|
|
763
778
|
PWN.send(:remove_const, :MqttSubThread) if PWN.const_defined?(:MqttSubThread)
|
|
764
779
|
Curses.close_screen
|
data/lib/pwn/version.rb
CHANGED