# SQL Server

1. Login to `WEB01` as the `Administrator` user with password `Welcome01!`.
2. Download SQL Server 2019 from [Microsoft Evaluation Center](https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2019).

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FDlkzu7tkmSLUzcDNJKk6%2Fimage.png?alt=media&#x26;token=93f77e51-ab65-4977-a0fc-0681f3fe285a" alt=""></div>

3\. When smartscreen comes up select "Run".

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FmjfjkuJNytcsYXCX6p1y%2Fimage.png?alt=media&#x26;token=007f0120-629b-42c6-835b-28c690507bff" alt=""></div>

{% hint style="info" %}
The SQL Server Installation may require internet access, temporally add a second adapter in the machine settings and select the NAT network. The machine should have internet access. (ps our first adapter is different since our lab runs on a ESXI host).

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F46Sj22Fv6O91HbPBzY2S%2Fimage.png?alt=media\&token=a3f89180-6a60-4099-9595-3ad6e1057c94)

{% endhint %}

4\. On "Select an installation type" select "Basic":

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2Fpee68sBozh1du1gtIN27%2Fimage.png?alt=media\&token=ef9d6bde-4902-42c7-a601-2bb2ea3edb18)

5\. Accept the License Terms and click "Install".

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FkzazOTdh9D2n75H85L1W%2Fimage.png?alt=media\&token=39545d1a-acca-4f03-a5e8-6353f1b69028)

6\. Once the installation is finished, click on "Customize".

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FPdX3DkaKCJS2sjWqS0WN%2Fimage.png?alt=media\&token=0322cb8e-e9a8-46bf-9595-155d3b13f7bd)

7\. Check "Use Microsoft Update to check for updates" and click next till the step "License Terms" and accept them:

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FrPdcIUCSqTanbOcpkvaQ%2Fimage.png?alt=media\&token=462b2ffc-2da8-4231-979a-50074238e7fa)

8\. At the step "Feature Selection" choose the following options:

* Database ENgine Services
* SQL Server Replication
* Client Tools Connectivity
* Client Tools SDK

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FWB5mjPePrpHhfMk4SWAW%2Fimage.png?alt=media\&token=c1a1bb51-d02b-4ac6-b966-bb1576a79c4e)

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FDbWovZdMLHJ9OtYwM41Q%2Fimage.png?alt=media&#x26;token=e81a0317-83c9-4d63-82b3-bfcd0f1a0570" alt=""></div>

9\. Click Next and fill in the Instance name `dev`.

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F7jbwEEwgJ7TD34qAaI9M%2Fimage.png?alt=media\&token=d4ca8d98-f64f-4dd5-b7b8-ed17f6857cdd)

10\. Change the "Startup Type" for the "SQL Serer Agent" to "Automatic" and make sure all three are set to "Automatic", click "Next".

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FVAbkwAVXz4johONvfSoN%2Fimage.png?alt=media\&token=006fba7d-815e-485f-9034-a128fc26836a)

11\. At the next step select "Mixed Mode" and fill in the password `Password1!`. Then select "Add" at the "Specify SQL Server administrators" and add `amsterdam\administrator` then click Next.

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FTUBqMA7soGha8QpSq0gK%2Fimage.png?alt=media\&token=200892ec-89dc-4c9b-b3e6-11756ae3fb81)

12\. Click "Install" and wait for the installation to finish.

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FMaLZ3RnZFNHvUCzU0OZD%2Fimage.png?alt=media\&token=f3ed2174-5c5a-4b17-9832-57f25ac0d4ec)

13\. Open the "SQL Configuration Manager".

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2Fewvhr2QvjqnxmM2Z9zuG%2Fimage.png?alt=media\&token=0fe1bb0f-7eeb-4d8b-a5db-d79adae60c5e)

13\. Expand "SQL Server Network Configuration" and select "Protocols for DEV". Double click on "TCP/IP" and select the "IP Addresses" tab. Fill in `1433` for "TCP Port".

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FKSk7FeqDcOiY2y5ekWQQ%2Fimage.png?alt=media&#x26;token=d0afd45c-5806-4c8b-ba87-79768e27abcb" alt=""></div>

14\. Scroll to the bottom and also configure IPAll:

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FVG7IXvLl04zOyeroHzrt%2Fimage.png?alt=media&#x26;token=fecf357a-7b6b-4191-bd75-7e391c89a4a0" alt=""></div>

14\. Then click "Apply".

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FQne6v1FuVuqW47rDDSa8%2Fimage.png?alt=media&#x26;token=446ad87d-9eae-43d7-a59b-c3c67524c161" alt=""></div>

15\. Open "SQL Server services" and right click on "SQL Server (DEV)" and click "Restart".

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F2qxxNGdDCQUHty9bmkBh%2Fimage.png?alt=media\&token=2e74e2fa-a428-408f-9ada-302187cc5aa1)

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F9MnbxRyjc1QqvxsfbEt6%2Fimage.png?alt=media&#x26;token=9976a9fa-982a-4446-959a-8f32375cb18b" alt=""></div>

16\. Do the same for "SQL Server Agent":

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2Fr27dVZj4AFIrGuGN4c15%2Fimage.png?alt=media&#x26;token=763ce4a9-60b5-47d9-bedf-5938b6835ccd" alt=""></div>

17\. Download and Install [SQL Server Mangement Studio](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?redirectedfrom=MSDN\&view=sql-server-ver15). Just Click "Install" and reboot the system.

### Configuring Windows Firewall for SQL Server

1. Search for "Windows Defender Firewall with Advanced Security" and select "Windows Defender Firewall with Advanced Security"

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FRXMnT1Jk9YTAT0BUUexx%2Fimage.png?alt=media&#x26;token=213f8715-b103-4836-9aec-da08a3dd0cf4" alt=""></div>

2\. Rightclick on "Inbound Rules" and select "New rule".

3\. Select "Port" and click "Next"

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F44XeseDszUIvDgxSQYo6%2Fimage.png?alt=media&#x26;token=9188f8ea-16ef-43e8-ad0e-27bf99322a97" alt=""></div>

4\. Make sure "TCP" is selected and fill in port `1433` and click "Next":

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FIvusvGWvo7aAcem3KhjJ%2Fimage.png?alt=media&#x26;token=c54b8542-8294-4544-b88d-fa54eece16c9" alt=""></div>

5\. Click next at the step "Profile". Fill in the name "Allow TCP 1433 MSSQL Server for all" and click "Finish":

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F7JNjBMm7xnEZQxADn2I1%2Fimage.png?alt=media&#x26;token=a7cda269-4df1-41e7-9a16-d10c4eec07e5" alt=""></div>

6\. When done remove the "NAT" adapter from the virtual machine.

### Testing connectivity

1\. Open the Kali machine and run a quick Nmap to check if the port is open:

```
sudo nmap -p 1433 10.0.0.5 -Pn -n

Starting Nmap 7.92 ( https://nmap.org ) at 2022-03-06 11:39 CET
Nmap scan report for 10.0.0.5
Host is up (0.017s latency).

PORT     STATE SERVICE
1433/tcp open  ms-sql-s

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ad-lab.gitbook.io/building-a-windows-ad-lab/lab-setup/building-the-lab/creating-bank.local/creating-amsterdam.bank.local/creating-webserver-web01/sql-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
