My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 1: Output of StringToBase64 is unusable with -EncodedCommand
1 person starred this issue and may be notified of changes. Back to list
Status:  Verified
Owner:  Nikhil.u...@gmail.com
Closed:  Jul 2013
Cc:  nishang-...@googlegroups.com


 
Project Member Reported by Nikhil.u...@gmail.com, Jul 11, 2013
What steps will reproduce the problem?
1. Encode a command using StringtoBase64
2. Use that command with powershell.exe -EncodedCommand <encodedstringhere>


What is the expected output? What do you see instead?
Powershell fails to execute it.

Revision 30 fixes this. Please update repos.

Original email report to me is copied below:
**************************************************************************

Hi
 
I found a problem about nishang on my computer.
 
look at the source code
 
StringToBase64.ps1
=========================================================================
Param( [Parameter(Position = 0, Mandatory = $True)] [String] $Str)
function StringtoBase64
{
 
  $utfbytes  = [System.Text.Encoding]::UTF8.GetBytes($Str)
  $base64utfstring = [System.Convert]::ToBase64String($utfbytes)
  $base64utfstring
  }
  StringToBase64
 
StringToBase64_MyTest.ps1
=========================================================================
Param( [Parameter(Position = 0, Mandatory = $True)] [String] $Str)
function StringtoBase64
{
 
  $unicodebytes  = [System.Text.Encoding]::Unicode.GetBytes($Str)
  $base64unicodestring = [System.Convert]::ToBase64String($unicodebytes)
  $base64unicodestring
  }
  StringToBase64
 
========================================================================
 
testing
--------------------------------------------------------------
powershell -executionpolicy Bypass -file C:\Users\Administrator\Documents\StringToBase64.ps1 -Str "dir 'c:\'"
ZGlyICdjOlwn
 
powershell -executionpolicy Bypass -file C:\Users\Administrator\Documents\StringToBase64_MyTest.ps1 -Str "dir 'c:\'"
ZABpAHIAIAAnAGMAOgBcACcA
 
result
------------------------------------------------------------------------------------------------------------------------
powershell -Encodedcommand ZGlyICdjOlwn               #some error like powershell.exe : The term '?????' is not recognized as the name of a cmdlet, function .....
powershell -Encodedcommand ZABpAHIAIAAnAGMAOgBcACcA   #succeed
 
 
I think there are some particular problems in encoding operations, the [System.Text.Encoding]::Unicode is better
 
thanks
--------------------------------------------------------------------------
**************************************************************************

Powered by Google Project Hosting