app service Azure

Dump Kudu logs and app files from webapp with Nodejs or powershell

Dumps log files from Azure App Service.

source https://github.com/projectkudu/kudu/wiki/REST-API

NodeJS

Dependencies include axios, and built in FS module

const {createWriteStream} =require('fs')
const axios = require('axios')

async function kuduc(u,p,site) {
 
    var base64 = Buffer.from(`${u}:${p}`).toString('base64')
    var s = {
        url:`https://${site}.scm.azurewebsites.net/api/dump`,
        headers: {
            "Authorization": "Basic " + base64},
            method:"get",
            responseType: 'stream'
    }
 
    var writes = createWriteStream('download.zip')
 
    const response = await axios(s).catch(error => console.log(error?.response))
 
    response.data.pipe(writes)
 
}


kuduc('$sqlicompromise','passowrd','sqlicompromise')

Powershell

$username = "`$yourwebsite"
$password = "password"
# Note that the $username here should look like `SomeUserName`, and **not** `SomeSite\SomeUserName`
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"

# Example 1: call the zip controller API (which uses PUT)
$apiUrl = "https://sqlicompromise.scm.azurewebsites.net/api/dump"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}  -UserAgent $userAgent -Method get -OutFile data.zip

Dump files (Powershell)

$username = "`$sqlicompromise"
$password = "sd"
# Note that the $username here should look like `SomeUserName`, and **not** `SomeSite\SomeUserName`
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"
 
# Example 1: call the zip controller API (which uses PUT)
$apiUrl = "https://sqlicompromise.scm.azurewebsites.net/api/zip/site/"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}  -UserAgent $userAgent -Method get -OutFile data.zip

0 comments on “Dump Kudu logs and app files from webapp with Nodejs or powershell

Jätä kommentti