metasploit-framework icon indicating copy to clipboard operation
metasploit-framework copied to clipboard

Add row indicator to `show targets` command

Open cgranleese-r7 opened this issue 2 years ago • 1 comments

This PR cannot be merged until this PR in rex-text is merged.

This PR adds support for row indicators for show targets command.

Expected output

image

JSON output

Output
{
   "header":"\nExploit targets:",
   "headeri":0,
   "columns":[
      "IsTarget",
      "Id",
      "Name"
   ],
   "rows":[
      [
         "false",
         "0",
         "Windows 2000 SP0-SP1 (Arabic)"
      ],
      [
         "false",
         "1",
         "Windows 2000 SP0-SP1 (Czech)"
      ],
      [
         "false",
         "2",
         "Windows 2000 SP0-SP1 (Chinese)"
      ],
      [
         "false",
         "3",
         "Windows 2000 SP0-SP1 (Dutch)"
      ],
      [
         "true",
         "4",
         "Windows 2000 SP0-SP1 (English)"
      ],
      [
         "false",
         "5",
         "Windows 2000 SP0-SP1 (French)"
      ],
      [
         "false",
         "6",
         "Windows 2000 SP0-SP1 (Finnish)"
      ],
      [
         "false",
         "7",
         "Windows 2000 SP0-SP1 (German)"
      ],
      [
         "false",
         "8",
         "Windows 2000 SP0-SP1 (Korean)"
      ],
      [
         "false",
         "9",
         "Windows 2000 SP0-SP1 (Hungarian)"
      ],
      [
         "false",
         "10",
         "Windows 2000 SP0-SP1 (Italian)"
      ],
      [
         "false",
         "11",
         "Windows 2000 SP0-SP1 (Portuguese)"
      ],
      [
         "false",
         "12",
         "Windows 2000 SP0-SP1 (Spanish)"
      ],
      [
         "false",
         "13",
         "Windows 2000 SP0-SP1 (Swedish)"
      ],
      [
         "false",
         "14",
         "Windows 2000 SP0-SP1 (Turkish)"
      ],
      [
         "false",
         "15",
         "Windows 2000 Pro SP0 (Greek)"
      ],
      [
         "false",
         "16",
         "Windows 2000 Pro SP1 (Greek)"
      ]
   ],
   "width":189,
   "indent":0,
   "cellpad":2,
   "prefix":"",
   "postfix":"",
   "colprops":[
      {
         "Width":2,
         "WordWrap":true,
         "Stylers":[
            {
               
            }
         ],
         "Formatters":[
            
         ],
         "ColumnStylers":[
            {
               
            }
         ]
      },
      {
         "Width":null,
         "WordWrap":true,
         "Stylers":[
            
         ],
         "Formatters":[
            
         ],
         "ColumnStylers":[
            
         ]
      },
      {
         "Width":null,
         "WordWrap":true,
         "Stylers":[
            
         ],
         "Formatters":[
            
         ],
         "ColumnStylers":[
            
         ]
      }
   ],
   "sort_index":1,
   "sort_order":"forward"
}

Note

Also made some changes to how headers were being handled in the show_targets method. It wasn't making use of Serializer::ReadableText.dump_exploit_targets(mod, ' ', "\nExploit targets:") method already being able to handle headers if they were passed. So made that changed as I thought it made more sense than adding it to the print statement below. Hopefully there wasn't unknown reasons for that but I couldn't see any reason.

Verification

This will need to be tested along side a rex-text PR. Follow prerequisite steps within that PR before completing the steps below.

  • [ ] Start msfconsole
  • [ ] run use windows/iis/ms01_023_printer
  • [ ] Verify show targets has a row indicator and works as expected
  • [ ] Change target by running set target 1 and verify row indicator adjusts as expected
  • [ ] Repeat steps for an evasion module

cgranleese-r7 avatar Aug 26 '22 11:08 cgranleese-r7

Not a blocker: It would be good to add this functionality to the show actions command too

adfoster-r7 avatar Jan 13 '23 00:01 adfoster-r7

@cgranleese-r7 This will need a gem update for rex-text once that's available in rubygems

adfoster-r7 avatar Feb 02 '23 12:02 adfoster-r7

Release Notes

Updates the show targets and show actions command to display a visual indicator beside the currently selected value

adfoster-r7 avatar Feb 02 '23 17:02 adfoster-r7