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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39f11158eacd6a873c2699f6f642591ed8b4de2ba64ce73f96b84f56f35a81e8
4
- data.tar.gz: '08b0fb7f0b619bfb20e1fb97b083a180c215a662f90383a43b22785e2e57e5fd'
3
+ metadata.gz: 0bd30ef667258a8c6d6f5b2f64b7a5d39791b79b2f70e874c15ea2f846cfc543
4
+ data.tar.gz: 43d46bd61ce79485b22640c37ede4e67ac44462d8f03c31c6bdeae40433fcd49
5
5
  SHA512:
6
- metadata.gz: fc7d789f23c35d20ab41229e87903c8a618da4fef1518b51291fe534b888a3d0cfcb36af7f824bef116f224034ba8e9d071a7e88fa1a7ad2cdb6b418fe2498db
7
- data.tar.gz: b36f00d2e5a3118c561415be867d14eae5b2ec54b6dac67c32840bc434585fac9a1f1633b2f81178b495f3900ee5f567b7c63c5b4402779826b1cd952fa63b64
6
+ metadata.gz: 61f58c0a487e678a1a33c9df4f75b5bf5b5360845fb5ab9a16acaa629c678df17430e1d99c75a0d6c94126b3aa3711de1f4d247af22789aed073570fcb63e1d2
7
+ data.tar.gz: 1c46a44f7590948fe513e063836a9b82db47ba455e05e0fab7b47c2d19cf58b394dc337d92c5edeb247d280c70ed198fce385c6fb9b23408df8387653dbd5b4d
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ Layout/LineLength:
6
6
  Lint/UselessRescue:
7
7
  Enabled: false
8
8
  Metrics/AbcSize:
9
- Max: 552.3
9
+ Max: 562.2
10
10
  Metrics/BlockLength:
11
11
  Max: 292
12
12
  Metrics/BlockNesting:
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.487]:001 >>> PWN.help
40
+ pwn[v0.5.489]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](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.487]:001 >>> PWN.help
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.487]:001 >>> PWN.help
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:
@@ -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, :MeshRxWin) if PWN.const_defined?(:MeshRxWin)
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(:MeshLastPair, PWN::MeshColors.sample)
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
- rx_win = Curses::Window.new(rx_height, Curses.cols, 0, 0)
512
+ rx_header_win = Curses::Window.new(rx_height, Curses.cols, 0, 0)
512
513
  # TODO: Scrollable but should stay below header_line
513
- rx_win.scrollok(true)
514
- rx_win.nodelay = true
515
- rx_win.attron(Curses.color_pair(cyan) | Curses::A_BOLD)
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
- rx_win.attron(Curses.color_pair(green) | Curses::A_BOLD)
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
- rx_win.setpos(1, rx_header_pos)
523
- rx_win.addstr(rx_header)
524
- rx_win.attroff(Curses.color_pair(green) | Curses::A_BOLD)
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
- rx_win.setpos(2, 0)
527
- rx_win.attron(Curses.color_pair(cyan) | Curses::A_BOLD)
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
- rx_win.addstr(header_line)
531
- rx_win.attroff(Curses.color_pair(cyan) | Curses::A_BOLD)
532
-
533
- rx_win.refresh
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
- last_drawn = nil
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 current_line != last_drawn
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
- last_drawn = current_line
604
+ last_line = current_line
597
605
  end
598
- sleep 0.0001
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
- rx_win = PWN.const_get(:MeshRxWin)
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 pair different from the last used one
643
+ # Select a random color different from the last used one
635
644
  colors_arr = PWN.const_get(:MeshColors)
636
- last_pair = PWN.const_get(:MeshLastPair)
637
- pair = last_pair
645
+ last_color = PWN.const_get(:MeshLastColor)
646
+ color = last_color
638
647
  unless last_from == from
639
- PWN.send(:remove_const, :MeshLastPair)
640
- pair_choices = colors_arr.reject { |c| c == last_pair }
641
- pair = pair_choices.sample
642
- PWN.const_set(:MeshLastPair, pair)
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
- rx_win.attron(Curses.color_pair(pair) | Curses::A_REVERSE)
650
- mutex.synchronize do
651
- inner_height = Curses.lines - 5
652
- inner_width = Curses.cols
653
- segments = current_line.scan(/.{1,#{inner_width}}/)
654
- segments.each do |seg|
655
- # TODO: Show new messages without scrolling above header line
656
- rx_win.scroll if rx_win.cury >= (inner_height - 1)
657
-
658
- rx_win.setpos(rx_win.cury, 0)
659
- # Handle wide Unicode characters for proper alignment
660
- display_width = Unicode::DisplayWidth.of(seg)
661
- width_diff = seg.length - display_width
662
- inner_width = Curses.cols + width_diff
663
- line = seg.ljust(inner_width)
664
- rx_win.addstr(line)
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
- rx_win.refresh
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?(:MeshRxWin)
753
- PWN.const_get(:MeshRxWin).close
754
- PWN.send(:remove_const, :MeshRxWin)
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, :MeshLastPair) if PWN.const_defined?(:MeshLastPair)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.5.487'
4
+ VERSION = '0.5.489'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.487
4
+ version: 0.5.489
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.