How to use Retargetable Decompiler cURL API? - linux

I'm on Windows and I'm trying to use the cURL API provided by Retargetable Decompiler. Since cURL is a Linux utility, I downloaded a Windows build from here. Let's say I want to perform the following decompilation:
This is using the browser which works and produces a result. Now when trying to do the same using cURL from the command line, I get errors.
Output:
>curl --form "mode=raw" --form "input=code.bin" --form "architecture=powerpc" --form "endian=big" --form "raw_entry_point=0x0" --form "raw_section_vma=0x0" -u my-secret-api-key: "https://retdec.com/service/api/decompiler/decompilations" { "id": "yVWe4pe5", "links": { "decompilation": "https://retdec.com/service/api/decompiler/decompilations/yVWe4pe5", "status": "https://retdec.com/service/api/decompiler/decompilations/yVWe4pe5/status", "outputs": "https://retdec.com/service/api/decompiler/decompilations/yVWe4pe5/outputs" }}
{
"code": 400,
"description": "The input file is missing.",
"message": "Missing Input File"
}
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: id
curl: (6) Could not resolve host: yVWe4pe5,
curl: (6) Could not resolve host: links
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: decompilation
{
"code": 405,
"description": "The method is not allowed for the requested URL.",
"message": "Method Not Allowed"
}
curl: (6) Could not resolve host: status
{
"code": 404,
"description": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"message": "Not Found"
}
curl: (6) Could not resolve host: outputs
{
"code": 405,
"description": "The method is not allowed for the requested URL.",
"message": "Method Not Allowed"
}
curl: (3) [globbing] unmatched close brace/bracket in column 1
Also yes, the code.bin is in the same directory as the command line (script). How can I make it work? I actually prefer a solution in Java and not cURL but doing it in cURL first might be easier for understanding since no Java examples or documentation is provided.

Nevermind, it's pretty straightforward.
Starting the process:
>curl --form "mode=raw" --form "input=#code.bin;filename=code.bin" --form "architecture=powerpc" --form "endian=big" --form "raw_entry_point=0x0" --form "raw_section_vma=0x0" --form "target_language=c" -u my-secret-api-key: "https://retdec.com/service/api/decompiler/decompilations"
Received (example) response:
{
"id": "mKgBoLa3jo",
"links": {
"decompilation": "https://retdec.com/service/api/decompiler/decompilations/mKgBoLa3jo",
"outputs": "https://retdec.com/service/api/decompiler/decompilations/mKgBoLa3jo/outputs",
"status": "https://retdec.com/service/api/decompiler/decompilations/mKgBoLa3jo/status"
}
}
Getting the decompiled (example) code:
>curl -u my-secret-api-key: https://retdec.com/service/api/decompiler/decompilations/r8OW7AaAOb/outputs/hll
//
// This file was generated by the Retargetable Decompiler
// Website: https://retdec.com
// Copyright (c) 2017 Retargetable Decompiler <info#retdec.com>
//
#include <stdint.h>
// ------------------- Function Prototypes --------------------
int32_t entry_point(int32_t a1);
int32_t unknown_20ca300(int32_t a1, int32_t a2);
int32_t unknown_212363c(int32_t a1);
int32_t unknown_27a2ad4(int32_t a1, int32_t a2);
// ------------------------ Functions -------------------------
// Address range: 0x0 - 0x1ef
int32_t entry_point(int32_t a1) {
int32_t result = a1; // r26
if (unknown_27a2ad4(a1, 0x27a2ad4) != 0) {
// 0x94
result = -1;
unknown_212363c(0);
unknown_20ca300(0, 0x830000);
// branch -> 0x54
}
// 0x54
return result;
}
// --------------------- Meta-Information ---------------------
// Detected compiler/packer: gcc (gcc-powerpc-elf) (4.5.1 - 4.5.2)
// Detected functions: 1
// Decompiler release: v2.2.1 (2016-09-07)
// Decompilation date: 2017-10-06 22:50:25
And so on.

Related

Unable to get data using requests.get while it works with curl

Im trying to get response using RESTCONF. When i use CURL as:
curl -X GET -H "Accept: application/yang-data+json" -H "Content-Type: application/yang-data+json" -k https://user:pass#IP/api/data/switch:opm/port={1,2}
I get output perfectly as
"switch:port": {
"port-id": 1,
"wavelength": "0000.0",
"offset": "0.0",
"averaging-time": 4 } } { "switch:port": {
"port-id": 2,
"wavelength": "0000.0",
"offset": "0.0",
"averaging-time": 0 } }
But when i use requests.get in python as:
url ="""https://IP/api/data/switch:opm/port={1,2}"""
response = requests.get(url,headers=self.header,auth =(self.username1,self.password1),verify=False)
I get response 404.
I tried port=1 and it works fine in python too. Facing issues when i use port={1,2}.

Failed executing transaction to invoke HyperLedger Fabric function using Kaliedo FabConnect API

I've been using Kaleido's FabConnect API to invoke some transactions from a sample fabric smart contract using this request:
curl -X 'POST'
'https://u0jzrmv8ok-u0nh6n12o1-connect.us0-aws-ws.kaleido.io/transactions?fly-sync=true'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '{
"headers": {
"type": "SendTransaction",
"signer": "user2",
"channel": "ustrades",
"chaincode": "asset_transfer"
},
"func": "GetAllAssets",
"args": [
"string"
],
"init": false
}'
but I get the following error: {
"error": "Failed to submit: error getting channel response for channel [ustrades]: Discovery status Code: (11) UNKNOWN. Description: error received from Discovery Server: failed constructing descriptor for chaincodes:<name:"asset_transfer" > "
}
I've seen a similar problem where the solution offered was to add anchor peer nodes, but how exactly do you do that on Kaleido. Their customer support is slow getting back to me, so I thought I'd ask here.

Github API - add an issue to a project?

Is it possible, using the github API, to add an Issue to a project board?
This document:
https://docs.github.com/en/rest/reference/projects#create-a-project-card
suggests it is possible, but my attempts using https://github.com/fastai/ghapi have failed.
I have tried:
api.projects.create_card(col.id, note=f'{issue.title} {issue.html_url}', content_id=issue.id)
but the card does not show up as an issue card, it shows up as a card referencing an issue - which is different.
I also tried:
curl -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/projects/columns/####/cards -d '{"column_id": colid, "content_id": cid, "content_type": "json"}' -u user:$GITHUB_TOKEN
and that gave an error:
{
"message": "Validation Failed",
"errors": [
{
"resource": "ProjectCard",
"code": "unprocessable",
"field": "data",
"message": "Could not resolve to a node with the global id of 'XXXXXXXXXX'."
}
],
"documentation_url": "https://docs.github.com/v3/projects/cards/#create-a-project-card"
}
which suggests that I've mucked up the curl request, but I'm not sure where.
I've found a solution following https://stackoverflow.com/a/57696731/814354. I need to declare the content_type in the POST request (which is information I was unable to find on the github documentation).
CURL version:
curl -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/projects/columns/{column_id}/cards -d '{"column_id": {column_id}, "content_id": {issue_id}, "content_type": "Issue"}' -u {username}:$GITHUB_TOKEN
The ghapi version does not work:
# this fails - `content_id` and `content_type` are not included in the request
api.projects.create_card(col.id, content_id=issue.id, content_type='Issue')
but you can still use the ghapi in a clunkier way:
api(path=f'/projects/columns/{col.id}/cards', verb='POST',
data={'content_id': issue.id,
'column_id': col.id,
'content_type': 'Issue'
},
headers={"Accept": "application/vnd.github.v3+json"}
)

Alpha release 'Deployed' but unavailable

I have built a Google Action using Dialogflow and having trouble releasing an updated version to Alpha today.
The updated action works OK in Draft and I submitted it for Alpha deployment. The Actions console is showing the release as "Deployed". However, when I try to access the Alpha version I get an "isn't responding right now" response (from the simulator, Home device and Assistant smartphone app). The backend fulfilment service which is shared by Draft and Alpha is working OK.
I can see the following in the Debug console on the simulator:
{
"response": "MyAction Test isn't responding right now. Try again soon.",
"expectUserResponse": false,
"conversationToken": "EucBS2o5Uk...",
"audioResponse": "//NExAAP+H...",
"ssmlMarkList": [],
"debugInfo": {
"assistantToAgentDebug": {
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=XXXXX&versionId=20' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: XXXXX' -A Google-ActionsOnGoogle/1.0 -X POST -d '{\"user\":{\"accessToken\":\"eyXXXXX\",\"locale\":\"en-US\",\"lastSeen\":\"2019-09-12T09:58:03Z\",\"userStorage\":\"{\\\"data\\\":{\\\"welcomes\\\":53,\\\"intentCounts\\\":{\\\"BALANCE\\\":2}}}\",\"userVerificationStatus\":\"VERIFIED\"},\"conversation\":{\"conversationId\":\"ABXXXXXX\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to MyAction Test\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.ACCOUNT_LINKING\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"}]},\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]}]}'",
"assistantToAgentJson": "{\"user\":{\"accessToken\":\"eyXXXXX\",\"locale\":\"en-US\",\"lastSeen\":\"2019-09-12T09:58:03Z\",\"userStorage\":\"{\\\"data\\\":{\\\"welcomes\\\":53,\\\"intentCounts\\\":{\\\"BALANCE\\\":2}}}\",\"userVerificationStatus\":\"VERIFIED\"},\"conversation\":{\"conversationId\":\"ABXXXXX\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to MyAction Test\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.ACCOUNT_LINKING\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"}]},\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]}]}",
"delegatedRequest": {
"delegatedRequest": ""
}
},
"agentToAssistantDebug": {
"agentToAssistantJson": "<!DOCTYPE html><html lang=en><meta charset=utf-8><meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\"><title>Error 400 (Not Found)!!1</title><style nonce=\"2YtDuE0THEDAcE3p1uuIgA\">*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{color:#222;text-align:unset;margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px;}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}pre{white-space:pre-wrap;}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}</style><div id=\"af-error-container\"><a href=//www.google.com><span id=logo aria-label=Google></span></a><p><b>400.</b> <ins>That’s an error.</ins><p>The requested URL was not found on this server. <ins>That’s all we know.</ins></div>",
"delegatedResponse": {
"delegatedResponse": ""
}
},
"sharedDebugInfoList": [],
"conversationBuilderExecutionEventsList": []
},
"visualResponse": {
"visualElementsList": [
{
"displayText": {
"content": "MyAction Test isn't responding right now. Try again soon."
}
}
],
"suggestionsList": [],
"agentLogoUrl": ""
},
"clientError": 0,
"is3pResponse": true,
"clientOperationList": [
{
"operationType": 4,
"startIndicatorPayLoad": {
"status": 1
}
},
{
"operationType": 7,
"exitIndicatorPayLoad": {
"status": 1
}
}
],
"projectName": "",
"renderedHtml": ""
}
And the Stackdriver log is showing:
2019-09-12 11:56:49.381 BST App returned an HTTP error. State: URL_ERROR
{
insertId: "1iedwiug2dbgn68"
labels: {
channel: "preview"
querystream: "GOOGLE_USER"
source: "AOG_REQUEST_RESPONSE"
}
logName: "projects/myaction-test/logs/actions.googleapis.com%2Factions"
receiveTimestamp: "2019-09-12T10:56:49.389233862Z"
resource: {
labels: {…}
type: "assistant_action"
}
severity: "ERROR"
textPayload: "App returned an HTTP error. State: URL_ERROR"
timestamp: "2019-09-12T10:56:49.381445860Z"
trace: "projects/XXXXX/traces/ABXXXXX"
}
Looking at Dialogflow, the Environments / versions view shows the status of the release as "Deploying", so there seems to be a mismatch between the Action and Dialogflow deployments..?
I have tried re-releasing to Alpha (original attempt was nearly 4 hours ago), but the same problem/ errors still exist. Both attempted releases are showing as "Deploying" in Dialogflow.
Has anyone seen this before? Any idea what the problem may be or how to resolve it?
Thanks!
No solution yet but I have opened a support request with logs that have the same error.
Haven't received a support response yet but did find a workaround.
Inside of the Dialogflow agent settings > Environments and under draft I was able to view all versions. The latest version that I was looking for did say "Ready". When I clicked on the three dots to the right I loaded it to draft. Then in the Actions on Google console I went to Deploy, then the alpha section and clicked "Submit for alpha". Almost immediately after deploying and seeing "Deployed", the skill was available again for the alpha users.
Definitely don't remember doing this previously.
Finally got a response from Google who said there was an "issue" that day. Seems to be working OK now

Error 403 when trying to connect to websocket api

I currently develop a realtime kik connector for the unification engine.To receive the messages, I connect to the websocket endpoint using my users name and password.Sadly, I get an error 403 everytime.Is there anything else I have to look out for?
Some examples:
$ curl -XPOST https://apiv2.unificationengine.com/v2/connection/list -u $USER_NAME:$PASSWORD --data "{}" -k -s | jq
{
"status": 200,
"info": "200 OK",
"connections": {
"kik": {
"uri": "kik://kik_user#kik.com"
}
}
}
Websocket:
$ wscat --auth "$USER_NAME:$PASSWORD" -c wss://apiv2.unificationengine.com/v2/ws/start
error: Error: unexpected server response (403)
Are you using this library?
https://github.com/websockets/wscat
Does this library support authentication in this way?
wscat --auth "$USER_NAME:$PASSWORD" -c wss://apiv2.unificationengine.com/v2/ws/start
Done research on this, wscat is using npm ws, https://github.com/websockets/ws for webscoket connection.
Can you try header like this and check
var ws = new WebSocket('wss://apiv2.unificationengine.com/v2/ws/start', {
origin: 'https://apiv2.unificationengine.com',
headers: { Authorization: 'base64 auth' }
});
You can create base64 auth like this in nodejs
var auth = "Basic " + new Buffer(USER_ACCESS_KEY + ":" + USER_ACCESS_SECRET).toString("base64");

Resources