블로그 이미지
LifeisSimple

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2015. 6. 23. 14:29 Brain Trainning/Server

로컬 혹은 원격 서버의 패스워드를 변경하기 위한 방법


출처 : http://community.spiceworks.com/how_to/1966-how-to-change-local-user-or-admin-passwords-on-remote-computers

Steps (4 total)

1

Obtain PSTools

2

Open the Command Console

To open the Command Console 
1. Click on Start 
2. Click on “Run” 
3. Type “CMD” in the “Run” box. 
4. Change the prompt to the PSTools folder by typing the full folder path. Example: C:\Blabla\PSTools

3

For a single computer

Inside the Command Console type: 

pspasswd.exe \\Remote_computer_name -u user_name -p new_password

Obviously you would replaced Remote_computer_name with the name of your remote PC, user_name with the actual username, and new_password with the actual new password for that user.

4

For a multiple computers:

1. Create a text file named PCs.txt or whatever you want .txt with the names of the PCs to change a given local user’s password. One computer name per line, no spaces or extra lines.

2. Save the text file in the PSTools folder for convenience or you’ll have to type the full file path in the command.

3. Inside the Command Console type: 
pspasswd.exe @pcs.txt -u user_name -p new_password

Conclusion

And that is all folks.
Visit http://technet.microsoft.com/en-us/sysinternals/bb897543 for more info.

PsPasswd v1.23

By Mark Russinovich

Published: October 17, 2012

 Download PsTools (1.6 MB)

Rate:  
 

Introduction

Systems administrators that manage local administrative accounts on multiple computers regularly need to change the account password as part of standard security practices. PsPasswd is a tool that lets you change an account password on the local or remote systems, enabling administrators to create batch files that run PsPasswd against the computers they manage in order to perform a mass change of the administrator password.

PsPasswd uses Windows password reset APIs, so does not send passwords over the network in the clear.

 

Installation

Just copy PsPasswd onto your executable path, and type "pspasswd" with the command-line syntax shown below..

 

Using PsPasswd

You can use PsPasswd to change the password of a local or domain account on the local or a remote computer.

usage: pspasswd [[\\computer[,computer[,..] | @file [-u user [-p psswd]]] Username [NewPassword]

computerPerform the command on the remote computer or computers specified. If you omit the computer name the command runs on the local system, and if you specify a wildcard (\\*), the command runs on all computers in the current domain.
@fileRun the command on each computer listed in the text file specified.
-uSpecifies optional user name for login to remote computer.
-pSpecifies optional password for user name. If you omit this you will be prompted to enter a hidden password.
UsernameSpecifies name of account for password change.
NewPasswordNew password. If ommitted a NULL password is applied.

 

Download

Download PsTools
(1.6 MB)



posted by LifeisSimple
2015. 3. 29. 11:12 Photograph by ../일상

경제의 교양을 읽는다 - 현대편


##경제의 교양을 읽는다.

#주류 경제학을 밖에서 비판하고 대안을 제시하다.

10. 상품에 의한 상품생산 (피에로 스라파)

- 자본주의 경제의 가장 중요한 특성은 자본을 사용하는 생산활동이다. 자본은 자본재 들의 집합이다. 그런데 자본재는 이중의 특성을 가지고 있다. 자본재는 다른 상품들을 생산하기 위해 사용되는 생산수단인 동시에, 그 자체가 경제 내에서 다른 자본재들에 의해 생산되는 상품이다. 다시 말해 자본재는 생산된 생산수단이다. 따라서 자본을 사용하는 생산활동, 즉 자본주의 경제의 특성은 ‘상품에 의한 상품 생산’이다.

11. 자본 축적론 (조앤 로빈슨)

- 조앤 로빈슨의 자본축적론은 가치 이론에 천착하여 주어진 자원의 효율적 배분의 문제로 경제학적 문제를 제한해온 신고전학파 경제학의 문제의식에 대한 비판인 동시에, 항상 유효수요의 문제에 직면해 있는 경제가 시간에 걸쳐 어떻게 변화해가는가를 영국 고전학파의 관전에사 바라보면서 (케인즈에서 시작하는) 현재적인 분석방법을 사용하려는 건설적인 시도이다.

12. 통화주의라는 재앙 (니콜라스 칼도어)

- 칼도어는 통화주의라는 재앙 을 인생 끝 무렵인 1982년에 출간하였다. 이 책에서 칼도어는 통화주의의 근간에 깔려 있는 화폐 개념, 현실에서 관찰 되는 경제현상에 대한 통화주의적 해석이 지닌 문제점, 그리고 통화주의의 정책 제안이 실제로 실현되었을 때 가져올 ‘재앙’을 명철하게 밝히고 비판한다. 칼도어는 케인즈나 밀턴 프리드먼과 같은 의미의 화폐이론가가 아니다.

#주류 경제학을 안에서 비판하고 확장하다 II

13. 경험에 기초한 미시경제학 (하버트 사이먼)

- 사이먼은 개별 경제주체를 현실에서는 존재할 수 없는 완전무결한 자동기계로 상정하여 이론을 펼치는 데 반대했다. 대신 경제주체는 계산과 정보처리 능력이 제한되어 있어, 휴리스틱이라는 체계적이지 않은 방법으로 선택 대안들을 탐색하며, 일정한 목표수준을 충족하는 대안이 생겨나면 바로 탐색을 중단하는 만족자 이지, 효용 극대화자가 아니라고 생각했다.

14. 행동경제학의 토대가 된 인지심리학 연구

- 현실에서 경제주체가 주류 경제학에서의 ‘이상화된 경제주체’와 어떻게 다른지를 카너먼의 연구는 잘 보여준다. 그렇다면 정책 수단을 통해 전자를 후자에 더욱 근접하도록 하는 것이 (인지)심리학을 토대로 한 경제학, 즉 행동경제학이 할 일인가 아니면 ‘이상화된 경제주체’의 상에 수정을 가하여 합리성의 기준을 바꾸는 것이 더욱 생산적일까? 카너먼은 이 문제에 대하 첫 번째 입장을 옹호한다. 그는 심리학을 미시적 기초로 하는 경제학을 실천하는 사회과학자는 개별 경제주체들 자신들보다 그 자신들이 행복해질 수 있는 방법을 더 잘 알 수 있다는 주장을 옹호하고, 온정주의에 원칙적으로 반대할 이유는 없다고 생각한다.

15. 경제학에서의 합리성 : 구성적 형태와 생태적 형태 (버논 스미스)

- 버논 스미스의 비인격적 교환/인격적 교환 이라는 2가지 주제의 실험은 다음과 같은 정형화된 사실을 낳았다. 첫째, 경쟁이 제대로 작동하여 효율성을 달성하는 시장이 존재하기 위한 조건에 시장참가자들이 완전한 정보를 갖고 있어야 한다는 점은 포함될 필요가 없다. 오히려 그러한 조건이 충족되는 경우 시장의 효율성이 저하되는 것을 스미스의 실험실 연구는 잘 보여준다. 둘째 인격적 교환 중 두 사람 사이의 일회적 상호작용만으로 그 결과가 결정되는 상황에서, 사회적 교환(상호 이익을 위한 협력)이 빈번하게 일어난다는 점이 알려지게 되었다. 즉 인격적 교환에 임하는 개인들은 타인을 고려하는 행위를 흔히 보인다는 결론이 받아들여지게 되었다.

#협의의 경제학을 넘어서

16. 치명적 자만 (프리드리히 하이에크)

- 사회주의가 이론적으로 오류라는 점을 사회주의자들에게 보이려는 목표를 갖고 있다. 그는 이 책에서도 사회주의를 비판하고 시장주의를 옹호하는 자신의 사회절학적 입장을 반복했는데, 다른 저작보다 더 넓은 시각에서 군더더기 없이 자신의 입장을 선명하게 드러냈다.

17. 자본주의, 사회주의, 민주주의 (조지프 슘페터)

- 자본주의의 안락사와 사회주의의 자연스런 도래를 예언했다. 슘페터는 여기서 마르크스의 예언에 동의했지만 노동가치론을 위시한 마르크스의 이론은 비판했다. 무엇보다 그는 마르크스와 달리 폭력혁명을 통해 자본주의를 타도할 필요가 없다고 주장했다. 사회주의를 위한 혁명은 경제적 혁명이지 결코 정치적 혁명이 되어서는 안 된다고 말한다. 이미 자본주의 내부에서 사회주의로의 점진적 이행을 촉진시키는 요인들이 등장했기 때문이다.

18. 풍요한 사회 (존 갤브레이스)

- 풍요한 사회는 경제성장에 성공해 풍요로운 미국 사회가 겪는 새로운 종류의 질병들에 대해 진단하고 처방했다. 그의 다른 책과 마찬가지로 경제를 정치 및 사회와 결합시켜 논의하였다. 또한 이를 위해 주류 경제학뿐만 아니라 과거의 중요 경제사상들을 근거로 활용했다.

19. 윤리학과 경제학 (아마티아 센)

- 센은 공리주의와 이에 근거한 신고전학파 경제학을 비판하면서 이에 대한 대안을 모색했다. 경제학과 역사적으로 긴밀한 관계에 있으며 현대의 경제학이 불가결한 기반으로 삼는 공리주의는 인간이 쾌락과 고통 등 감정을 가진 존재라는 점을 주목하면서 이에 근거해 이론과 이념을 설정했다. 경제학은 1870년대에 인간이 합리적이라고 주장하면서 공리주의를 받아들여, 쾌락과 고통을 계산해 이를 극대화할 수 있는 능력으로 인간의 합리성을 파악했다. 그 후 경제학은 효용이론을 선택이론으로 변화시켰다.

20. 갈등의 전략 (토머스 쉘링)

- 쉘링이 이 책에서 분석하는 상황들은 모두 비협조적 게임의 상황이다. 쉘링은 전략적 상황에 놓은 합리적인 개인들이 어떻게 자신의 이득을 극대화하기 위해 행동하는가를 아주 치밀한 논리 전개로 분석하였다. 쉘링이 드는 예들은 당시 국제관계에서 초미의 관심사였던 군비증강처럼 무척이나 심각하고 무거운 주제부터 약속 장소를 정하는 문제처럼 사소해 보이지만 매일매일의 일상에서 우리가 마주치는 아주 현실적이고 구체적인 문제들까지 포괄한다. 쉘링이 이야기하듯 이 책에 실린 에세이들은 ‘순수’연구와 ‘응용’연구의 혼합물이다.



posted by LifeisSimple
2014. 10. 15. 17:39 Brain Trainning/DataBase

 

Decrypting MSSQL Database Link Server Passwords

 

출처 : https://www.netspi.com/blog/entryid/221/decrypting-mssql-database-link-server-passwords

 

Extracting cleartext credentials from critical systems is always fun. While MSSQL server hashes local SQL credentials in the database, linked server credentials are stored encrypted. And if MSSQL can decrypt them, so can you using the PowerShell script released along with this blog. From the offensive point of view, this is pretty far into post exploitation as sysadmin privileges are needed on the SQL server and local administrator privileges are needed on the Windows server. From the defensive point of view, this is just another reminder that unnecessary database links, database links with excessive privileges, and the use of SQL server authentication rather than integrated authentication can result in unnecessary risk. This blog should be interesting to database hackers and admins interested in learning more.

Linked Servers

Microsoft SQL Server allows users to create links to external data sources, typically to other MSSQL servers. When these links are created, they can be configured to use the current security context or static SQL server credentials. If SQL server credentials are used, the user account and password are saved to the database encrypted and thus they are stored in a reversible format. A one-way hash cannot be used, because the SQL server has to be able to access the cleartext credentials to authenticate to other servers. So, if the credentials are encrypted and not hashed, there must be a way for the SQL server to decrypt them prior to use. The remainder of this blog will focus on how that happens.

Linked Server Password Storage

MSSQL stores link server information, including the encrypted password, in master.sys.syslnklgns table. Specifically, the encrypted password is stored in the "pwdhash" column (even though it's not a hash). Below is an example:

The master.sys.syslnklgns table cannot be accessed using a normal SQL connection, but rather a Dedicated Administrative Connection (DAC) is needed (more information about DAC at http://technet.microsoft.com/en-us/library/ms178068%28v=sql.105%29.aspx). Sysadmin privileges are needed to start a DAC connection, but as local administrator privileges are needed anyways, that shouldn't be a problem. If local administrators don't have sysadmin privileges you'll just have to impersonate the MSSQL server account or local SYSTEM account. More details on this can be found on Scott's blog at https://www.netspi.com/blog/entryid/133/sql-server-local-authorization-bypass.

MSSQL Encryption

Time to introduce some MSSQL encryption basics. To move ahead, access to the Service Master Key (SMK) is required (more information about SMK at http://technet.microsoft.com/en-us/library/ms189060.aspx). According to microsoft.com "The Service Master Key is the root of the SQL Server encryption hierarchy. It is generated automatically the first time it is needed to encrypt another key." SMK is stored in master.sys.key_encryptions table and it can be identified by the key_id 102. SMK is encrypted using Windows Data Protection API (DPAPI) and there are two versions of it in the database; one encrypted as LocalMachine and the other in the context of CurrentUser (meaning the SQL Server service account here). We'll choose the former to extract the key as LocalMachine encryption uses the Machinekey for encryption and it can be decrypted without impersonating the service account. Below is an example of what that looks like:

Additional entropy is added to strengthen the encryption but the entropy bytes can be found in the registry at HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\[instancename]\Security\Entropy. Once again, local administrator privileges are needed to access the registry key. The entropy is stored in the registry for each MSSQL instance as shown below:

After that (and removing some padding / metadata from the encrypted value) we can decrypt the SMK using DPAPI.

Decrypting Linked Server Passwords

Based on the length of the SMK (or the MSSQL version) we can determine the encryption algorithm: MSSQL 2012 uses AES, earlier versions use 3DES. In additional, the pwdhash value has to be parsed a bit to find the encrypted password. The first answer referring Pro T-SQL Programmer's guide at http://stackoverflow.com/questions/2822592/how-to-get-compatibility-between-c-sharp-and-sql2k8-aes-encryption got me on the right track; even though the byte format didn't seem to match exactly like detailed on the page, it wasn't too hard to find the right bytes to encrypt. So now, using the SMK, it is possible to extract all of the link credentials (when SQL Server account is used, not Windows authentication) in cleartext.

Decrypting Linked Server Passwords with PowerShell - Get-MSSQLLinkPasswords.psm1

To automate the decryption of linked server credentials I wrote a PowerShell script called "Get-MSSQLLinkPasswords.psm1". It can be download from GitHub here:
https://github.com/NetSPI/Powershell-Modules/blob/master/Get-MSSQLLinkPasswords.psm1

The script must be run locally on the MSSQL server (as DPAPI requires access to the local machine key). The user executing the script must also have sysadmin access to all the database instances (for the DAC connection) and local admin privileges on the Windows server (to access the entropy bytes in registry). In addition, if UAC is enabled, the script must be ran as an administrator. Below is a summary of the process used by the script.

  1. Identify all of the MSSQL instances on the server.
  2. Attempt to create a DAC connection to each instance.
  3. Select the encrypted linked server credentials from the "pwdhash" column of the "mas-ter.sys.syslnklgns" table for each instance.
  4. Select the encrypted Service Master Key (SMK) from the "master.sys.key_encryptions" table of each instance where the "key_id" column is equal to 102. Select the version that has been encrypted as LocalMachine based on the "thumbprint" column.
  5. Extract the entropy value from the registry location HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\[instancename]\Security\Entropy.
  6. Use the information to decrypt the SMK.
  7. The script determines the encryption algorithm (AES or 3DES) used to encrypt the SMK based on SQL Server version and SMK key length.
  8. Use the SMK to decrypt the linked server credentials.
  9. If successful, the script displays the cleartext linked server credentials. Below is an example of the end result:

I've tested the script with MSSQL 2005, 2008, 2012, 2008 Express, and 2012 Express. There might be some bugs, but it appears to work reliably. Please let me know if you notice any errors or if I did not account for certain situations etc.

'Brain Trainning > DataBase' 카테고리의 다른 글

[MSSQL] 버전 별 페이징 쿼리  (0) 2016.04.06
[MSSQL] DB 백업사이즈  (0) 2016.04.04
[MSSQL] 2012 버전별 기능  (0) 2013.09.23
[MSSQL] 2000 -> 2005 시스템뷰 매핑  (0) 2013.08.05
[MSSQL] Database 서버 전체 복구  (0) 2013.02.20
posted by LifeisSimple