// 불펌스크립트시작 // 불펌스크립트 끝

제어판 → 프로그램 및 기능 → Windows 기능 켜기/끄기 에서 아래 스크린 샷처럼 .NET Framework 3.5(.NET 2.0 및 3.0 포함)을 활성화하는 식으로 닷넷 3.5를 설치하려고 시도해 봤는데요,



아래 스크린 샷처럼 오류 코드 : 0x800F0906 를 뿜으면서 더이상 진행되지 않아서 설치가 불가능한 증상이 있었습니다.



온라인 상에서 해결해 보려고 애를 써봤지만 잘 안돼서, 윈도우 설치할 때 썼던 ISO파일에 내장된 닷넷 3.5를 설치하는 식으로 해결을 했습니다.


일단 윈도우 ISO 파일을 마운트하거나 설치USB를 꼽고, 해당 드라이브에 sources\sxs 폴더가 있는지 확인합니다. 확인했으면...

화면 좌측하단 시작버튼에서 마우스 우클릭 → 명령프롬프트(관리자) 를 선택합니다. (아래 스샷 참고)



명령프롬프트(관리자) 창에 아래의 명령을 참고하여 입력합니다. 



DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:e:\sources\sxs

위 명령에서 붉게 표시한 e: 은 윈도우 ISO(혹은 USB)가 마운트된 드라이브 명으로 수정해야 합니다.



조금 기다리면 위 스크린 샷처럼 작업완료 메세지가 뜰겁니다. 그럼 설치가 끝난 겁니다.

제어판 → 프로그램 및 기능 → Windows 기능 켜기/끄기 로 진입해보면 아래 스크린샷처럼 닷넷 3.5가 활성화되어 있는 것을 확인할 수 있을겁니다.



Slack Messaging with the AWS IoT Button

Update: James Hurst has created an incredible Udemy course on doing exactly this, go check it out! It’s FREE!

Udemy Course: https://www.udemy.com/aws-iot-slackbot/learn/v4/overview

Amazon recently released the AWS IoT Button as a one-click button that allows you to do “IoT related tasks.” Seeing that I work at an “IoT related” company, and work out of the Think Big Coworking space, an AWS IoT button to do something around the office was a must.

We weren’t entirely sure what to do with the AWS IoT buttons we had, but after some thought and a few Slack messages about the coffee being out on the different floors, it seemed obvious. The button should message our community-connector that coffee is needed on the floor.

Slack is a huge part of the community at Think Big Coworking. It’s a great way to stay up to date with what is happening in the building, as well as communicate with other members. This is why we think a button that ties into Slack, is the perfect use-case for our space. Everyone is always on Slack, and who doesn’t like fresh coffee?

Follow this guide, and within 30-minutes you’ll be sending Slack messages to a channel of your choosing.

AWS IoT Button

Guide

First thing you’ll want to do is clone or download my GitHub repository located at: https://github.com/cpiggott/LambdaToSlack

You can clone it with the git clone command:

git clone https://github.com/cpiggott/LambdaToSlack.git

or

Click Clone or download and Download ZIP

If you downloaded it by clicking ‘Download Zip’ you’ll need to extract the files. On Windows, right-click on the file and click ‘Extract all…’ on Mac, double-click on the .zip file in Finder and it should create an extracted version.

Slack Configuration

Next thing you’ll want to do is head over to Slack and create a web-hook for your Slack Team. This requires Admin privileges on Slack.

In the Slack application, click the drop-down arrow to the right of your teams name and select ‘Apps & integrations.’

Click Apps & integrations

This will open up the browser with your teams Apps and Integraitons, you’ll need to navigate to the ‘Build’ part of Slack to create a new integration for your channel.

Top right menu of Slack, click Build

You’ll then receive two options: An app for other Slack teams, or Something for just my team. Select “Something just for my team.”

Select Make a Custom Integration

Once you click “Make a Custom Integration,” you’ll be prompted with these options, select “Incoming WebHooks.”

Select Incoming WebHooks

You’ll now be prompted with an option to select a channel that the webhook works for, this part is entirely up to you. We created a new channel that is used specifically for coffee. We called it #coffee and added the webhook, as well as other employees that might need to know to refill the coffee. You can also create webhooks to send as direct messages.

Choose a channel and click Add Incoming WebHooks Integraiton

After selecting your channel and clicking the “Add Incoming WebHooks Integration”, you’ll be sent to the configuration page for the Webhook. This page will look like the image below.

Slack WebHook configuration page.

From this page you can see all of the different settings that you can tweak for your webhook. We decided that since this was a coffee-bot, why not customize the name and icon to have something to do with coffee.

You’ll now need to copy the Webhook URL for use in the next part of the guide. Don’t forget to click Save Settings if you’ve customized the look and name of your integration.

Head over to the files that you extracted and open up the main.py file with your favorite text editor. The code should look like below:

import requests
def handler(event, context):
requests.post('insert your url between these quotes',json={"text" : "Insert your message between these quotes, slack emotes like :coffee: work in the text body" })

Where it says ‘insert your url between these quotes’ is where you will… well… insert your URL.

Next, customize your message to say whatever you want it to. You can insert different emoji’s within the message, here is an example of what we have:

:three: : Coffee is out on the *3rd floor*. More please! :coffee:

Once you have customized your message and placed it between the quotes for the message part of the code, your final main.py should look something like this:

import requests
def handler(event, context):
requests.post(‘https://hooks.slack.com/services/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',json={"text" : “:three: : Coffee is out on the *3rd floor*. More please! :coffee:” })

Once you are finished with the main.py file, save it and close your editor.

AWS Configuration

Next, we need to sign up for an Amazon AWS account. Go to the AWS IoT Button website at https://aws.amazon.com/iot/button/ and you’ll find a button saying “Create an Account”. Go through the process of signing up. This will require a credit card, but the first 1-million calls per month to your code are free, so this isn’t going to cost you anything to run.

After signing up for an AWS account, you now need to head to the AWS Dashboard. At the top of the page, there is a drop-down called “Services”, mouse-over the services tab, and click “Lambda” in the menu.

Select Lambda from the menu.

When you get to the Lambda page, you will be prompted to create a new Lambda Function. The next part of this guide will walk you through what I found to be the trickiest part of this whole process.

Click the “Create a Lambda Function” button on the Lambda services pages. After clicking, you’ll be prompted with pre-built Lambda functions known as Blueprints. At the bottom there is a button to skip this and create your own. Press the Skip button to move on to create a custom Lambda.

I’m going to work on creating a Blueprint for this so you don’t have to mess with the code, but that will come as I find the documentation to create a blueprint. If you know anymore about doing so, please tweet it to me @nullrefexc

Press Skip when you see this page.

At this point, you are prompted with a text editor to write code, we aren’t going to do this, instead we are going to upload the code that we wrote earlier.

Head back to finder or your file explorer where main.py is currently stored, and we now need to package all the code together to in a .zip file for AWS. This part is confusing in the AWS documentation, so I am documenting it here. DO NOT ZIP THE FILE THAT ALL THE FILES RESIDE IN. We need to zip the contents of the file with only the items we need. These files are:

  • main.py
  • requests
  • requests-2.10.0.dist-info

To select only these three files, hold the Ctrl button on your keyboard, and click on the the three files needed, they should highlight. You will now need to zip them, right click on one of the selected files, and click Send To… and select Compressed file. It will prompt you to change the name of the file, call it whatever you want.

Select these three files.
After compressing, I renamed the file to main.zip

Once we have finished compressing the file, we can head back to AWS to configure our Lambda.

You’ll want to set the configurations to match the following image. The Name and description is up to you, but you will need to select Python 2.7 for the Runtime.

You will also upload the .zip file we just created by clicking the “Upload a .ZIP file” option and then clicking Upload.

Set you configuration to closely match the above.

We now need to get into the Lambda function handler/role and Advanced settings. You will need to set the Handler to main.handler.

main.handler represents the piece of code that needs to execute. So we want the handler function in the main.py file to execute here.

What your Handler should look like.

Next we need to select a Role for the code to use. This requires heading to an external page by clicking on an item in the drop-down menu. Click the drop-down menu and select “*Basic execution role.” This should open up a new page, with the Role permissions. Simply click Allow at the bottom of the page that popped up and head back to your Lambda configuration.

Once you have created a Role and selected it, the rest of the configuration should look like the image below. Once it is all set, click Next.

Final settings for Lambda function.

You’ll be prompted with a Review screen to confirm all your settings. If everything looks good, click “Create function.”

Confirm your Lambda Function settings.

You will be kicked back to the functions dashboard now, at the top there is a button to Test you code. You can click that button to confirm that it works.

Click Test

Clicking the Test button for the first time will prompt you to create a test to run, select the Hello World example and click Save and test.

Test Configuration

If everything worked, you should see a message in the Slack channel that you created your webhook for. Here is an example of the message I sent when I clicked Test.

Message sent from “coffee-bot”

Now that our messages are being fired, we need to set-up the last part of this, which is the AWS IoT button.

Head back to your browser and the dashboard for the Lambda function we created. We need to select the “Event sources” tab from the dashboard. Click the “Add event source” and a dialog pops-up. Select AWS IoT and the dialog should bring up more options. Choose the “IoT Button” from the “IoT type”drop-down. This can be seen below.

Enter your IoT serial and you’ll be given instructions on setting up your IoT button.

When you click “Generate certificates and keys” you will be given a set of instructions on how to connect to the IoT button. Makes sure to download the certificate.pem and private.key files before connecting to your IoT buttons.

Follow the directions provided by AWS and follow the guide provided here. Once your device is configured, re-connect to your network, and click Submit. You should receive a green dialog confirming that the button was configured correctly and the light on the AWS IoT button should turn green.

You are now set to use your IoT button as you configured it. We decided to stick ours to a sign and set it next to the coffee dispensers. It’ll be nice to know when a fresh brew is on the way to floor. Check out the sign we made, with emoji’s of course.

Sign next to the coffee dispenser.
Slack messages from clicking the button.

If you have any questions about how to set this up, please feel free to reach out to me on Twitter. Also, I’m interested in what other end up doing with these, could be cool to see.

Reach me here: https://twitter.com/nullrefexc or @nullrefexc on most other social platforms.

As it turns out, these buttons are now sold out and aren’t expected to be in-stock until August. You can order them here and receive them when they are available: http://www.amazon.com/AWS-IoT-Button-Limited-Programmable/dp/B01C7WE5WM


Nmap 사용법

# nmap [1.스캔유형] [2.옵션] [호스트(ip)]


1. 스캔 유형

-sS : TCP SYN 스캔(스텔스 스캔)

-sT : TCP 연결을 사용한 포트스캔

-sP : Ping을 이용한 스캔

-sA : ACK 패킷에 대한 TTL값을 분석한다.(방화벽 규칙상태 확인시 사용)

-sR : RPC를 이용하여 포트를 스캔한다.

-sW : 윈도우 스캔은 ACK 스캔과 같은데 특정 장치에 대해 열린, 닫힌 포트를 구별한다.

-sI : Idel 스캔을 가장 은밀한 스캔, 느리고 복잡하다.

-sU : UDP 포트스캔

-sF : FIN 패킷을 이용하여 스캔한다.

-sX : Xmas 패킷을 이용하여 스캔한다.

-sN : Null 패킷을 이용하여 스캔한다.


2. 옵션

2-1. 포트 옵션

-p 22 : 22번 포트 스캔

-p (service) : 서비스 명으로 포트스캔

-p 20, 40, 80 : 20, 40, 80 포트스캔

-p 1-1023 : 1~1023 포트스캔, 범위로 지정


2-2 output 옵션

-v : 출력을 자세하게

-w : -v보다 더 자세하게

-oN <File명> : 일반 파일 형식으로 출력

-oX <File명> : XML 파일 형식으로 출력


2-3. 기타옵션

-O : 대상 호스트 운영체제 스캔

-PN : 호스트가 살아있는지 ping을 하지 않음으로 log 파일에 기록될 가능성을 줄인다.


2-4. 핑스캔

-sP : 핑 스캔(ICMP) 사용, 내부단은 ARP 요청이 대신함

-sL : 목록 스캔(서버가 살았는지 죽었는지 확인하는 좋은 방법)

-PS : TCP SYN 패킷을 보낸다. (SYN -> SYN, ACK -> RST)

-PA : TCP ACK 패킷을 보낸다. (위의 -PS와 비슷하지만 방화벽을 우회하기 위해 ACK를 보낸다.)

-PU : UDP핑, 빈UDP패킷을 해당 포트를 보낸다. TCP 필터링을 피해간다.

-PO : IP 프로토콜 핑, ICMP, IGMP, IP패킷을 이용한 스캔

-PR : ARP 스캔


3. 간단 사용 예

nmap -v 192.168.1.* : 해당 호스트의 정보를 조금 더 자세하게 보여준다.

nmap 192.168.1.*/16 : 네트워크 전체를 스캔한다.

nmap -sp 192.168.1.* : 192.168.1.*가 살아있는지 스캔한다.

nmap -sR -p 1-20000 192.168.1.200 : 192.168.1.200의 1번부터 20000까지 RPC 포트를 찾는다.

nmap -sU -PT 192.168.1.200/16 : 192.168.1.200 네트워크 호스트들에게 ACK 보내 응답을 기다리고 열려진 UDP 포트를 찾는다.

+ Recent posts