2024年4月15日星期一

[Python]Use Python to send form data to page

 Consider to request a form URL to get the site accept the data.

import requests # Define the form data form_data = { 'name': 'G X', 'email': 'gx@gx.com' } # Send a POST request with the form data response = requests.post('http://gx.com/submit', data=form_data) # Check if the request was successful (status code 200) if response.status_code == 200: print('Form submitted successfully') else: print('Failed to submit the form')


But actually, it won't work for the site I had expected.

Because the site will use a one-time serial session id to identify the request. need to update.

Yes, you are right. this is a tips for company timecard registration automation. 

 

2024年4月13日星期六

Cloud Service Comparison Cheat Sheet

 Just got one sheet for comparison 4 cloud services difference.


Hope can help someone, including me.


2024年4月12日星期五

[Letsencrypt]Import Letsencrypt on AWS EC2 Instance

I have a site need to be implemented on AWS EC2 with SSL for my daughter.

We already have some sites with test running on it.

So we set up VirtualHost for it.

After it can work on AWS EC2, I imported Certbot for it.

It is a installed package with AWS Linux already and this is a subdomain for gxlcs.com, like temp.gxlcs.com.

We only have few steps need to do.

1. sudo yum install certbot

2. sudo systemctl start certbot-renew.timer

3. sudo certbot certonly

4. 

How would you like to authenticate with the ACME CA?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

1: Runs an HTTP server locally which serves the necessary validation files under

the /.well-known/acme-challenge/ request path. Suitable if there is no HTTP

server already running. HTTP challenge only (wildcards not supported).

(standalone)

2: Saves the necessary validation files to a .well-known/acme-challenge/

directory within the nominated webroot path. A seperate HTTP server must be

running and serving files from the webroot path. HTTP challenge only (wildcards

not supported). (webroot)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Enter email address (used for urgent renewal and security notices)

 (Enter 'c' to cancel): webmaster@gxlcs.com


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Please read the Terms of Service at

https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf. You must agree in

order to register with the ACME server. Do you agree?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

(Y)es/(N)o: Y


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Would you be willing, once your first certificate is successfully issued, to

share your email address with the Electronic Frontier Foundation, a founding

partner of the Let's Encrypt project and the non-profit organization that

develops Certbot? We'd like to send you email about our work encrypting the web,

EFF news, campaigns, and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

(Y)es/(N)o: N

Account registered.

Please enter the domain name(s) you would like on your certificate (comma and/or

space separated) (Enter 'c' to cancel): temp.gxlcs.com

Requesting a certificate for temp.gxlcs.com

Input the webroot for temp.gxlcs.com: (Enter 'c' to cancel): 


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 does not exist or is not a directory

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Input the webroot for temp.gxlcs.com: (Enter 'c' to cancel): /var/www/html/temp


Successfully received certificate.

Certificate is saved at: /etc/letsencrypt/live/temp.gxlcs.com/fullchain.pem

Key is saved at:         /etc/letsencrypt/live/temp.gxlcs.com/privkey.pem

This certificate expires on 2024-07-11.

These files will be updated when the certificate renews.

Certbot has set up a scheduled task to automatically renew this certificate in the background.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

If you like Certbot, please consider supporting our work by:

 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate

 * Donating to EFF:                    https://eff.org/donate-le

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

5. sudo systemctl is-enabled httpd

if the response is [disabled], need to run #6.

6.  sudo systemctl start httpd && sudo systemctl enable httpd

7.  sudo yum update -y

8.  sudo yum install -y mod_ssl

9. After #8, it will create a conf file with name ssl.conf in /etc/httpd/conf.d/

10. sudo nano /etc/httpd/conf.d/ssl.conf

11. specify the [SSLCertificateFile] and [SSLCertificateKeyFile] with the path where you keep the key and certificate.

12. sudo systemctl restart httpd.service

13. Because we have VirtualHost, you also may need to change VirtualHost setup with where you put the DocumentRoot and Server Name.

14. As we have permitted the 443 port traffic in AWS Console, I mean inbound rule under security group, so the traffic is not problem.

15. I use CLOUDFLARE to provide security for site (Free version), so we also need to add a CNAME DNS record for this site. You can enter the AWS EC2 Instance tag, then confirm public DNS name which will be used in CLOUDFLARE CNAME DNS record CONTENT. 

OK, Now your site will go ahead in the net with SSL.

I will add the screenshot when I have time, sorry for any inconvenience.


Additional: I also have a security test for the site.

you can refer to below URL: 

Qualys

 

 

2024年4月11日星期四

[Python]JPG to PNG Python Program

from PIL import Image import os def convert_jpg_to_png(input_folder, output_folder): # 1. Get list up the input folder files jpg_files = [f for f in os.listdir(input_folder) if f.endswith('.jpg')] # 2. Create the output folder if it did not exist os.makedirs(output_folder, exist_ok=True) # 3. Change the JPG to PNG files for jpg_file in jpg_files: jpg_path = os.path.join(input_folder, jpg_file) # Create the PNG file output path png_path = os.path.join(output_folder, os.path.splitext(jpg_file)[0] + '.png') # Change the image img = Image.open(jpg_path) img.save(png_path, 'PNG') if __name__ == "__main__": input_folder = "path" # Define the input path of JPG output_folder = "path" # Define the output path of PNG convert_jpg_to_png(input_folder, output_folder)

Need to get them work on my site...

2023年10月18日星期三

[LEGO EV3]Battery Checker

 Created this for our little robot team.


It is simple but it can help you to detect your LegoEV3 battery status quickly after you created a base line for it in competitions.
Yes, I am their coach.

“Although we did not get enough score to enroll the WRO in Panama this year, I think our team will win in next year. “ teammate said.






2023年8月25日星期五

[Windows]License for windows95_WIndow95のライセンス解析

It is real that someone is still checking with old OS license key.

They are the heroes of internet.



  「Windows 11」ではデジタルライセンス認証も可能になったが、Windowsを使い始めるには、正規品であることを証明するために数桁のユニークな英数字「プロダクトキー」の入力が求められる。

 ある研究者は興味本位で「Windows 95」のプロダクトキーを解析したところ、ある法則によって生成されていたことが分かった。本質を理解すれば、誰でも簡単にプロダクトキーを生成できてしまうという。その法則とは?

 セキュリティ研究者のstacksmashing氏は、Windows OSのプロダクトキー認証を突破できる裏ワザを発見した。同氏はさまざまなデバイスやアプリ、ゲーム機などをハッキングしてはその模様をYouTubeに投稿している。Windowsのプロダクトキーに関する話も動画で取り上げられた話題の一つだ。

 ただし、この裏ワザが通用するのは「Windows 95」のインストール時のみだ。Windows 95は1995年8月25日に英語版が、同年11月23日に日本語版が発売され、今のWindowsの礎を築いたOSと言っても過言ではない。

 stacksmashing氏が解明したプロダクトキーの生成アルゴリズムについて、詳しく解説しよう。

 Windows 95のプロダクトキーは「XXX-YYYYYYY」というように「-(ハイフン)」で接続された10桁(前半3桁と後半7桁)の数字で構成される。同氏は試行錯誤しながらそのプロダクトキーを入力する中で、ある傾向をつかんだ。

 まず、「111-1111111」と全て「1」にするとインストールは成功する。また、全て「0」の場合でも成功する。そして前半3桁を「000」「001」「567」と変更し、後半7桁が全て「1」の場合も有効なキーと認識される。ただし「333」「444」「555」といった「0」や「1」「2」以外の3連続の数字を入力した場合は失敗するようだ。

 後半7桁は「0000001」だと失敗し、そこから1ずつ数を増やしていったところ「0000007」の場合は成功することが分かった。それを繰り返していくと、後半の数字は「0000000」「0000007」「0000016」「0000025」だと成功することが判明した。同氏は、後半7桁の各数字の合計が「7の倍数」であれば成功するのでは、と推測した。確かに「1111111」も全て合算すれば「7」だ。

 stacksmashing氏はリバースエンジニアリングツール「Ghidra」を使って禁断のプログラム解析を敢行した。すると前半3桁は「333」「444」「555」「666」「777」「888」「999」の数字がブラックリスト入りしているだけで、その他の3桁の数字なら何でもいいことが判明した。そして後半7桁については、同氏の予測通り、全ての桁の数字を合計して7で割り切れれば成功することが分かった。しかも、3桁と7桁の間の文字はチェックされておらず、必ずしも「-(ハイフン)」である必要がない。

 これらの情報をまとめると「前半3桁は3~9の3並び以外なら何でもいい」「前半と後半をつなぐ文字はどれでもいい」「後半7桁は合計したとき『7』で割り切れればいい」と単純なものだったのだ。

 ちなみに、このアルゴリズムはWindows 95リテール版で通用するものであり、OEM版はまた異なる。OEM版の場合、プロダクトキーは「AAABB-OEM-XXXXXXX-YYYYY」という形式(「A」「B」「X」「Y」はそれぞれ整数、「OEM」は固定の文字列)で構成されているが、これも単純なアルゴリズムだ。

 stacksmashing氏の解析をまとめると「AAA」は「1~366」で、「BB」は「00~02」または「95~99」、「XXXXXXX」は先頭が「0」で、かつ合算して7で割り切れる7桁の数字、そして「YYYYY」はノーチェック、つまり「何でもいい5桁の数字」だ。何とも単純な仕様だ。

2023年2月14日星期二

[RaspBerry Pi]How to expand the root partition of your Raspberry PI’s SD card

 How to expand the root partition of your Raspberry PI’s SD card?

After installing a new OS on your PI’s SD card you might notice there is a lot of diskspace ‘missing’ on the card…

By expanding the root partition of the card you can regain that ‘missing’ space!

This is the easiest way to do it:

  • open the PI’s configuration screen (in the terminal window) by typing:
    sudo raspi-config
  • run the bottom option just to make sure you have the latest version of the configuration software:
    update
  • run the second option:
    expand_rootfs
  • click:
    Finish
  • select ‘YES‘ when it asks for a reboot