pwn 0.5.309 → 0.5.311

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: 04b9816658aabc56840644ad45c4ad7a7acb67f2115027eaabdb2745c6305571
4
- data.tar.gz: 2dfcea55bc83eefbb84e1bad2ee900d760acf8271a2ddac00badebe421411985
3
+ metadata.gz: cf124a838b0f13e7e6e2ac3d13d354fd885c07f7c71c24e05134cf33dd66ba10
4
+ data.tar.gz: 0e4413b5365adadf3d7fc688ccf372d6caf8145ba8876bb0c6d65b6145048279
5
5
  SHA512:
6
- metadata.gz: dd2ef466bcb48f2110f569f25645213c9d3ab6e6d71dedbed6b465b46e3f85995d067f87708326009d14f23d8f84fbf28669d9114df3034afbd04a2495dc5fef
7
- data.tar.gz: e3111e88a91cc06a6ee9a950feda54527918ab27b5c2cfaa174128dfcd79185acc6d8eef9c0592fe1a30a5c4d5c83a273359be5246ff9be89b8dc761e5231ec3
6
+ metadata.gz: caf9d4f9fd676258b3405562f9ece2e85cfedcce57e83360e4b536ab2222c25487ccf19c82d19d3a26f07311d8f635222c9ffd765404cbda42d357593ddbbd18
7
+ data.tar.gz: 5ff6987e379badb54018ea566e5f288188a7e99e3c40d6fc27b13189cdde1eb9e5d45a42d4b2b510cacb270ee79c0465a21f014903671b317164fb650bb3c3df
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.309]:001 >>> PWN.help
40
+ pwn[v0.5.311]: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.309]:001 >>> PWN.help
55
+ pwn[v0.5.311]: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.309]:001 >>> PWN.help
65
+ pwn[v0.5.311]: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:
@@ -461,7 +461,8 @@ module PWN
461
461
  # Supported Method Parameters::
462
462
  # console_resp = PWN::Plugins::TransparentBrowser.console(
463
463
  # browser_obj: browser_obj1,
464
- # js: 'required - JavaScript expression to evaluate'
464
+ # js: 'required - JavaScript expression to evaluate',
465
+ # return_to: 'optional - return to :console or :stdout (defaults to :console)'
465
466
  # )
466
467
 
467
468
  public_class_method def self.console(opts = {})
@@ -469,13 +470,20 @@ module PWN
469
470
  verify_devtools_browser(browser_obj: browser_obj)
470
471
 
471
472
  js = opts[:js] ||= "alert('ACK from => #{self}')"
473
+ return_to = opts[:return_to] ||= :console
474
+ raise 'ERROR: return_to parameter must be :console or :stdout' unless %i[console stdout].include?(return_to.to_s.downcase.to_sym)
472
475
 
473
476
  browser = browser_obj[:browser]
474
477
  case js
475
478
  when 'clear', 'clear;', 'clear()', 'clear();'
476
479
  script = 'console.clear()'
477
480
  else
478
- script = "console.log(#{js})"
481
+ case return_to.to_s.downcase.to_sym
482
+ when :stdout
483
+ script = "return #{js}"
484
+ when :console
485
+ script = "console.log(#{js})"
486
+ end
479
487
  end
480
488
 
481
489
  console_resp = nil
@@ -511,29 +519,141 @@ module PWN
511
519
  )
512
520
 
513
521
  js = <<~JAVASCRIPT
514
- // Select the target node to observe
522
+ // Select the target node to observe (replace 'target-id' with your element's ID or use document.body)
515
523
  const targetNode = document.getElementById(#{target}) || document.body;
516
524
 
517
- // Configuration for observer
518
- const config = { attributes: true, childList: true, subtree: true };
525
+ // Configuration for MutationObserver
526
+ const config = {
527
+ attributes: true, // Observe attribute changes
528
+ childList: true, // Observe additions/removals of child nodes
529
+ subtree: true, // Observe descendants
530
+ characterData: true, // Observe text content changes
531
+ };
519
532
 
520
- // Callback for mutations
533
+ // Callback function to handle mutations
521
534
  const callback = (mutationList, observer) => {
522
- for (const mutation of mutationList) {
535
+ console.group('DOM Mutation Detected');
536
+ mutationList.forEach((mutation, index) => {
537
+ console.log(`Mutation ${index + 1}:`, mutation.type);
538
+
523
539
  if (mutation.type === 'childList') {
524
- console.log('Child node added/removed:', mutation);
540
+ if (mutation.addedNodes.length) {
541
+ mutation.addedNodes.forEach((node) => {
542
+ if (node.nodeType === Node.ELEMENT_NODE) {
543
+ let logObj = {
544
+ tagName: node.tagName,
545
+ id: node.id || 'N/A',
546
+ classList: node.className || 'N/A',
547
+ outerHTML: node.outerHTML,
548
+ };
549
+ if (['SCRIPT', 'IFRAME', 'FRAME', 'OBJECT', 'EMBED', 'APPLET'].includes(node.tagName)) {
550
+ console.warn('Potential XSS sink: Added', node.tagName, logObj);
551
+ } else {
552
+ console.log('Added Element:', logObj);
553
+ }
554
+ } else if (node.nodeType === Node.TEXT_NODE) {
555
+ console.log('Added Text Node:', {
556
+ textContent: node.textContent,
557
+ parentTag: node.parentElement?.tagName || 'N/A',
558
+ });
559
+ }
560
+ });
561
+ }
562
+ if (mutation.removedNodes.length) {
563
+ mutation.removedNodes.forEach((node) => {
564
+ if (node.nodeType === Node.ELEMENT_NODE) {
565
+ console.log('Removed Element:', {
566
+ tagName: node.tagName,
567
+ id: node.id || 'N/A',
568
+ classList: node.className || 'N/A',
569
+ outerHTML: node.outerHTML,
570
+ });
571
+ } else if (node.nodeType === Node.TEXT_NODE) {
572
+ console.log('Removed Text Node:', {
573
+ textContent: node.textContent,
574
+ parentTag: node.parentElement?.tagName || 'N/A',
575
+ });
576
+ }
577
+ });
578
+ }
525
579
  } else if (mutation.type === 'attributes') {
526
- console.log(`Attribute ${mutation.attributeName} modified:`, mutation);
580
+ let logObj = {
581
+ element: mutation.target.tagName,
582
+ id: mutation.target.id || 'N/A',
583
+ attribute: mutation.attributeName,
584
+ oldValue: mutation.oldValue,
585
+ newValue: mutation.target.getAttribute(mutation.attributeName),
586
+ outerHTML: mutation.target.outerHTML,
587
+ };
588
+ if (
589
+ (mutation.attributeName === 'src' && ['SCRIPT', 'IFRAME', 'FRAME', 'OBJECT', 'EMBED'].includes(mutation.target.tagName)) ||
590
+ (mutation.attributeName === 'href' && ['A', 'AREA', 'LINK'].includes(mutation.target.tagName)) ||
591
+ (mutation.attributeName === 'action' && mutation.target.tagName === 'FORM') ||
592
+ mutation.attributeName.startsWith('on') ||
593
+ (mutation.attributeName === 'srcdoc' && mutation.target.tagName === 'IFRAME') ||
594
+ (mutation.attributeName === 'data' && mutation.target.tagName === 'OBJECT') ||
595
+ (mutation.attributeName === 'codebase' && mutation.target.tagName === 'OBJECT')
596
+ ) {
597
+ console.warn('Potential XSS sink: Attribute change', logObj);
598
+ } else {
599
+ console.log('Attribute changed:', logObj);
600
+ }
601
+ } else if (mutation.type === 'characterData') {
602
+ if (mutation.target.parentElement && mutation.target.parentElement.tagName === 'SCRIPT') {
603
+ console.warn('Potential XSS sink: Script content changed', {
604
+ scriptId: mutation.target.parentElement.id || 'N/A',
605
+ oldValue: mutation.oldValue,
606
+ newValue: mutation.target.textContent,
607
+ });
608
+ } else {
609
+ console.log('Text Content Changed:', {
610
+ element: mutation.target.parentElement?.tagName || 'N/A',
611
+ id: mutation.target.parentElement?.id || 'N/A',
612
+ oldValue: mutation.oldValue,
613
+ newValue: mutation.target.textContent,
614
+ innerHTML: mutation.target.parentElement?.innerHTML || 'N/A',
615
+ });
616
+ }
527
617
  }
528
- }
618
+ });
619
+ console.groupEnd();
529
620
  };
530
621
 
531
- // Create and start observer
622
+ // Create and start the MutationObserver
532
623
  const observer = new MutationObserver(callback);
533
624
  observer.observe(targetNode, config);
625
+
626
+ // Optional: Add event listeners to capture user interactions
627
+ const logUserInteraction = (event) => {
628
+ console.group('User Interaction Detected');
629
+ console.log('Event Type:', event.type);
630
+ console.log('Target:', {
631
+ tagName: event.target.tagName,
632
+ id: event.target.id || 'N/A',
633
+ classList: event.target.className || 'N/A',
634
+ value: 'value' in event.target ? event.target.value : 'N/A',
635
+ innerHTML: event.target.innerHTML || 'N/A',
636
+ });
637
+ console.groupEnd();
638
+ };
639
+
640
+ // Attach listeners for keyboard and click events
641
+ document.addEventListener('input', logUserInteraction); // For form inputs, contenteditable
642
+ document.addEventListener('click', logUserInteraction); // For clicks
643
+
644
+ // Function to stop the observer (run in console when needed)
645
+ window.hide_dom_mutations = () => {
646
+ observer.disconnect();
647
+ document.removeEventListener('input', logUserInteraction);
648
+ document.removeEventListener('click', logUserInteraction);
649
+ console.log('MutationObserver and event listeners stopped.');
650
+ };
651
+
652
+ // Log instructions to console
653
+ console.log('MutationObserver started. To stop, run: hide_dom_mutations()');
534
654
  JAVASCRIPT
535
655
 
536
- console(browser_obj: browser_obj, js: 'console.clear();')
656
+ console(browser_obj: browser_obj, js: 'clear();')
537
657
  browser = browser_obj[:browser]
538
658
  browser.execute_script(js)
539
659
  rescue StandardError => e
@@ -542,54 +662,33 @@ module PWN
542
662
 
543
663
  # Supported Method Parameters::
544
664
  # console_resp = PWN::Plugins::TransparentBrowser.hide_dom_mutations(
545
- # browser_obj: browser_obj1,
546
- # target: 'optional - target JavaScript node to observe (defaults to document.body)'
665
+ # browser_obj: browser_obj1
547
666
  # )
548
667
 
549
668
  public_class_method def self.hide_dom_mutations(opts = {})
550
669
  browser_obj = opts[:browser_obj]
551
670
  verify_devtools_browser(browser_obj: browser_obj)
552
671
 
553
- target = opts[:target] ||= 'undefined'
554
-
555
672
  jmp_devtools_panel(
556
673
  browser_obj: browser_obj,
557
674
  panel: :console
558
675
  )
559
676
 
560
677
  js = <<~JAVASCRIPT
561
- // Select the target node to observe
562
- const targetNode = document.getElementById(#{target}) || document.body;
563
-
564
- // Configuration for observer
565
- const config = { attributes: true, childList: true, subtree: true };
566
-
567
- // Callback for mutations
568
- const callback = (mutationList, observer) => {
569
- for (const mutation of mutationList) {
570
- if (mutation.type === 'childList') {
571
- console.log('Child node added/removed:', mutation);
572
- } else if (mutation.type === 'attributes') {
573
- console.log(`Attribute ${mutation.attributeName} modified:`, mutation);
574
- }
575
- }
576
- };
577
-
578
- // Create and start observer
579
- const observer = new MutationObserver(callback);
580
- observer.observe(targetNode, config);
581
-
582
- // Later, stop observing if needed
583
- observer.disconnect();
678
+ if (typeof hide_dom_mutations === 'function') {
679
+ hide_dom_mutations();
680
+ console.log('DOM mutation observer and event listeners disabled.');
681
+ } else {
682
+ console.log('Error: hide_dom_mutations function not found. DOM mutation observer was not active.');
683
+ }
584
684
  JAVASCRIPT
585
685
 
586
- console(browser_obj: browser_obj, js: 'console.clear();')
686
+ console(browser_obj: browser_obj, js: 'clear();')
587
687
  browser = browser_obj[:browser]
588
688
  browser.execute_script(js)
589
689
  rescue StandardError => e
590
690
  raise e
591
691
  end
592
-
593
692
  # Supported Method Parameters::
594
693
  # PWN::Plugins::TransparentBrowser.update_about_config(
595
694
  # browser_obj: browser_obj1,
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.309'
4
+ VERSION = '0.5.311'
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.309
4
+ version: 0.5.311
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.