Can't POST to config_edit form - 418 "I'm a teapot"

Topics about terminal servers that doesn't fall into other categories.
Post Reply
ogabrielluiz
Posts: 12
Joined: Wed Apr 03, 2019 5:45 pm

Can't POST to config_edit form - 418 "I'm a teapot"

Post by ogabrielluiz » Fri May 03, 2019 4:02 pm

Hello!

Thanks for this awesome software.

I am trying to make a POST request to the form in config_edit but I'm getting the 418 "I'm a teapot" error.

I've tried POSTing the text directly and tried a multipart file giving "config.wtc" as the name.

Code: Select all

URL = "https://192.168.15.15/config_edit"
new_config_file = {"config_save":('config.wtc',"""server=192.367.192
                    bpp=16
                    turnoffmenu=always
                    disk=usb
                    keyboard=pt-br
                    connection""")}    
    
post = s.post(URL, auth=('', '123456'), files=new_config_file)
Or this using text instead of multipart:

Code: Select all

# Here I tried "config", "config_save", "config.wtc"
new_config = {"config_save":"""server=192.367.192 
                    bpp=16
                    turnoffmenu=always, msg: "Aguardando tecla..."
                    disk=usb
                    keyboard=pt-br
                    connection"""}
post = s.post(URL, auth=('', '123456'), data=new_config)
Can someone help me? I'm kinda new to this.

Thanks

aka
SUPPORT
SUPPORT
Posts: 670
Joined: Fri Dec 03, 2004 2:05 pm
Contact:

Re: Can't POST to config_edit form - 418 "I'm a teapot"

Post by aka » Sat May 04, 2019 11:53 am

WTware http server is very trivial. We test it from IE/Chrome/Mozilla only.

What language is it? Write me full source file so i can test it on my stand.

ogabrielluiz
Posts: 12
Joined: Wed Apr 03, 2019 5:45 pm

Re: Can't POST to config_edit form - 418 "I'm a teapot"

Post by ogabrielluiz » Mon May 06, 2019 2:49 pm

I was able to do it by creating a config.wtc file and uploading it through the upload_config_file form.

I'm having trouble now with encoding. For some reason when I upload the file I get this in the config_edit page:

Code: Select all

癲牥ㄽ㈹㌮㜶ㄮ㈹ †戠灰ㄽਸ਼††畴湲景浦湥㵵污慷獹‬獭㩧∠杁慵摲湡潤琠捥慬⸮∮ †搠獩㵫獵੢††敫批慯摲瀽⵴牢 †挠湯敮瑣潩
I am encoding it to utf-8, passing the data as a multiline string like so:

Code: Select all

new_config = """server=192.367.192
    bpp=16
    turnoffmenu=always, msg: "Aguardando tecla..."
    disk=usb
    keyboard=pt-br
    connection"""
Do you want me to create another thread for this?

ogabrielluiz
Posts: 12
Joined: Wed Apr 03, 2019 5:45 pm

Re: Can't POST to config_edit form - 418 "I'm a teapot"

Post by ogabrielluiz » Mon May 06, 2019 3:59 pm

ogabrielluiz wrote:
Mon May 06, 2019 2:49 pm
I was able to do it by creating a config.wtc file and uploading it through the upload_config_file form.

I'm having trouble now with encoding. For some reason when I upload the file I get this in the config_edit page:

Code: Select all

癲牥ㄽ㈹㌮㜶ㄮ㈹ †戠灰ㄽਸ਼††畴湲景浦湥㵵污慷獹‬獭㩧∠杁慵摲湡潤琠捥慬⸮∮ †搠獩㵫獵੢††敫批慯摲瀽⵴牢 †挠湯敮瑣潩
I am encoding it to utf-8, passing the data as a multiline string like so:

Code: Select all

new_config = """server=192.367.192
    bpp=16
    turnoffmenu=always, msg: "Aguardando tecla..."
    disk=usb
    keyboard=pt-br
    connection"""
Do you want me to create another thread for this?
The python script
script.txt
(1.31 KiB) Downloaded 14 times

aka
SUPPORT
SUPPORT
Posts: 670
Joined: Fri Dec 03, 2004 2:05 pm
Contact:

Re: Can't POST to config_edit form - 418 "I'm a teapot"

Post by aka » Tue May 07, 2019 11:22 pm

'config.wtc' on disk is utf-16. Two bytes per symbol. 'Unicode' encoding in windows Notepad. Replace in your script:

Code: Select all

with open('config.wtc', 'w', encoding='utf-8') as f:
with

Code: Select all

with open('config.wtc', 'w', encoding='utf-16') as f:

ogabrielluiz
Posts: 12
Joined: Wed Apr 03, 2019 5:45 pm

Re: Can't POST to config_edit form - 418 "I'm a teapot"

Post by ogabrielluiz » Wed May 08, 2019 3:16 pm

Oh!
I knew it was the encoding but I couldn't even guess what was the right one.

Thanks!

Post Reply