{
  "id": 343931,
  "title": "How to encode or decode string in WAF, base64 may cause error?",
  "url": "/competitions/ai-village-ctf/discussion/343931",
  "author_name": "MikaQAQ",
  "post_date": "2022-08-13T04:59:47.796000",
  "votes": 7,
  "comment_count": 3,
  "views": 0,
  "content": "<ul>\n<li>base64.b64decode(\"mFzaC==\") <br>\nwill cause error.<br>\nAnd when I submit </li>\n<li>input = base64.b64encode(some specific string).decode()<br>\nI may get a {'error': 'base 64 decoding error'}<br>\nThat's a little confused…</li>\n</ul>",
  "messages": [
    {
      "id": 1896720,
      "postDate": "2022-08-13T04:59:47.797Z",
      "content": "<ul>\n<li>base64.b64decode(\"mFzaC==\") <br>\nwill cause error.<br>\nAnd when I submit </li>\n<li>input = base64.b64encode(some specific string).decode()<br>\nI may get a {'error': 'base 64 decoding error'}<br>\nThat's a little confused…</li>\n</ul>",
      "rawMarkdown": "- base64.b64decode(\"mFzaC==\") \nwill cause error.\nAnd when I submit \n- input = base64.b64encode(some specific string).decode()\nI may get a {'error': 'base 64 decoding error'}\nThat's a little confused...\n\n",
      "votes": 7
    },
    {
      "id": 1897195,
      "postDate": "2022-08-13T14:29:03.343Z",
      "content": "<p><a href=\"https://www.kaggle.com/mikaqaq\" target=\"_blank\">@mikaqaq</a> This example from Getting Started v7 should work for you:</p>\n<pre><code># Submission Helper\n\nimport base64\n\ninput = \"mFzaC==\"\ndata = json.dumps(\n    {\"input\": input}\n)\n\ntry:\n    r = requests.post(\"https://waf.fly.dev/score\", data=data)\n    print(r.text)\nexcept requests.exceptions.ConnectionError:\n    print(\"Connection problems. Contact the CTF organizers.\")\n</code></pre>\n<p>Does that answer your question?</p>",
      "rawMarkdown": "@mikaqaq This example from Getting Started v7 should work for you:\n\n```\n# Submission Helper\n\nimport base64\n\ninput = \"mFzaC==\"\ndata = json.dumps(\n    {\"input\": input}\n)\n\ntry:\n    r = requests.post(\"https://waf.fly.dev/score\", data=data)\n    print(r.text)\nexcept requests.exceptions.ConnectionError:\n    print(\"Connection problems. Contact the CTF organizers.\")\n```\n\nDoes that answer your question?",
      "votes": 1,
      "replies": [
        {
          "id": 1897207,
          "postDate": "2022-08-13T14:44:03.567Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 1897208,
          "postDate": "2022-08-13T14:44:57.993Z",
          "content": "<p>Yes, Thanks very much.</p>",
          "rawMarkdown": "Yes, Thanks very much."
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1897195,
      "author_name": "Joe Lucas",
      "author_url": "",
      "post_date": "2022-08-13T14:29:03.343000",
      "content": "<p><a href=\"https://www.kaggle.com/mikaqaq\" target=\"_blank\">@mikaqaq</a> This example from Getting Started v7 should work for you:</p>\n<pre><code># Submission Helper\n\nimport base64\n\ninput = \"mFzaC==\"\ndata = json.dumps(\n    {\"input\": input}\n)\n\ntry:\n    r = requests.post(\"https://waf.fly.dev/score\", data=data)\n    print(r.text)\nexcept requests.exceptions.ConnectionError:\n    print(\"Connection problems. Contact the CTF organizers.\")\n</code></pre>\n<p>Does that answer your question?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1897207,
          "author_name": "",
          "author_url": "",
          "post_date": "2022-08-13T14:44:03.567000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1897208,
          "author_name": "MikaQAQ",
          "author_url": "",
          "post_date": "2022-08-13T14:44:57.993000",
          "content": "<p>Yes, Thanks very much.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1896720": "- base64.b64decode(\"mFzaC==\") \nwill cause error.\nAnd when I submit \n- input = base64.b64encode(some specific string).decode()\nI may get a {'error': 'base 64 decoding error'}\nThat's a little confused...\n\n",
    "1897195": "@mikaqaq This example from Getting Started v7 should work for you:\n\n```\n# Submission Helper\n\nimport base64\n\ninput = \"mFzaC==\"\ndata = json.dumps(\n    {\"input\": input}\n)\n\ntry:\n    r = requests.post(\"https://waf.fly.dev/score\", data=data)\n    print(r.text)\nexcept requests.exceptions.ConnectionError:\n    print(\"Connection problems. Contact the CTF organizers.\")\n```\n\nDoes that answer your question?"
  }
}