亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 4710 | 回復(fù): 14
打印 上一主題 下一主題

[學(xué)習(xí)共享] 一個小標(biāo)點引發(fā)一串匪夷所思的問題........ [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2013-01-03 22:39 |只看該作者 |倒序瀏覽
本帖最后由 wwr 于 2013-01-05 20:48 編輯

今天在寫有關(guān)通過shadow文件確定賬號是否符合安全標(biāo)準(zhǔn)的腳本:檢查賬戶有效期、檢查賬戶是否設(shè)置密碼等等。
首先看看這個檢查賬戶有效期的腳本,主要是截取shadow文件第八段,判斷賬戶的過期時間,并echo警告信息。
  1.         while IFS=: read -r f1 f2 f3 f4 f5 f6 f7 f8
  2.           do
  3.           if [ ! -z $f8 ]
  4.           then
  5.         expd="`date -d "1970-01-01+$f8 day" '+%Y-%m-%d'`"
  6.         echo -e "$ATT The account: $f1 will expried at $expd. Please contact your administrator!"
  7.         else echo -e "Checking account $f1 expire date.                $OK"
  8.         fi
  9.         done</etc/shadow
復(fù)制代碼
我們來執(zhí)行一下
  1. [root@butter ~]# ./secure.sh
  2. ........
  3. Checking account gopher expire date.            [  OK  ]
  4. ***Attention***    The account: john will expried at 2013-03-04. Please contact your administrator!
  5. Checking account nobody expire date.            [  OK  ]
  6. .....
  7. [root@butter ~]# cat /etc/shadow|grep john
  8. john:$6$hX2SaZv8$TZbICUPboyu2XmVVgYOfDFqvR7sKJeD0N5D2pvmxo3H8bmVl8eCroOLcJYEw6.uvkfQwgg/8b2wV1dvszi79a.:15708:0:99999:7::15768:
復(fù)制代碼
一切順利,只要對這個賬戶設(shè)定的密碼過期時間,他都能準(zhǔn)確的根據(jù)第八段時間計算出過期時間。

接著我們來檢查賬戶是否設(shè)置密碼。其實和上面的腳本幾乎一樣,唯一改變的是替換成第二字段,只要第二字段不為空我們就認(rèn)為他是有密碼的。腳本內(nèi)容如下
  1.         while IFS=: read -r f1 f2 f3 f4 f5 f6 f7 f8
  2.           do
  3.           if [ -z $f2 ]
  4.           then
  5.         echo -e "$WAR The account: $f1 has empty password! Please contact your administrator!"
  6.         fi
  7.         else -e "Checking whether the  account $1 has set a password         $OK"
  8.         done</etc/shadow
復(fù)制代碼
結(jié)果執(zhí)行之后離奇的出現(xiàn)錯誤
  1. ./secure.sh: line 4: [: too many arguments
復(fù)制代碼
腳本內(nèi)容完全是參照檢查賬戶有效期的那個來修改的,而且沒有任何錯別字。但就是無法解釋。
我試圖讓腳本不進(jìn)行判斷,只輸出$f2的內(nèi)容:
  1. [root@butter ~]# cat secure.sh
  2. while IFS=: read -r f1 f2 f3 f4 f5 f6 f7 f8
  3. do
  4. echo $f2
  5. done</etc/shadow
  6. [root@butter ~]# ./secure.sh
  7. $2y$10$ULX4kt.sVMbsjg0bBwj8FuCF9Exy2GzxnpgbCOZLf.Jtj5FQ7.DjC
  8. ALL_LINE Desktop Documents FLAG UNIQ_LINE autoinst.xml bin inst-sys passwd passwd2 secure.sh st
  9. ALL_LINE Desktop Documents FLAG UNIQ_LINE autoinst.xml bin inst-sys passwd passwd2 secure.sh st
  10. ALL_LINE Desktop Documents FLAG UNIQ_LINE autoinst.xml bin inst-sys passwd passwd2 secure.sh st
  11. ALL_LINE Desktop Documents FLAG UNIQ_LINE autoinst.xml bin inst-sys passwd passwd2 secure.sh st
  12. .............
復(fù)制代碼
除了第一行顯示正常的密碼字段以外其余的全是奇怪的內(nèi)容……

后來我又檢查了一下/etc/shadow文件:
  1. [root@butter ~]# cat /etc/shadow
  2. root:$2y$10$ULX4kt.sVMbsjg0bBwj8FuCF9Exy2GzxnpgbCOZLf.Jtj5FQ7.DjC:15705::::::
  3. bin:*:15385::::::
  4. daemon:*:15385::::::
  5. lp:*:15385::::::
  6. mail:*:15385::::::
  7. news:*:15385::::::
  8. uucp:*:15385::::::
  9. games:*:15385::::::
  10. man:*:15385::::::
復(fù)制代碼
仿佛發(fā)現(xiàn)了些什么…………



原來,系統(tǒng)默認(rèn)賬戶下的第二字段是星號,表示賬戶無法登錄。
而在腳本中,星號又是一個通配符,剛才通過echo看到的一串奇怪的內(nèi)容其實是我當(dāng)前目錄下的文件,你現(xiàn)在也可以試試"echo *"輸出結(jié)果等于"ls"。
恍然大悟了吧!立馬重新修改腳本,把剛才判斷語句中的$f2給加個雙引號。再跑一下。
Bravo!成功了!

  1. [root@butter ~]# cat secure.sh
  2.         while IFS=: read -r f1 f2 f3 f4 f5 f6 f7 f8
  3.         do
  4.         if [ -z "$f2" ]
  5.         then
  6.         echo -e "$WAR The account: $f1 has empty password! Please contact your administrator!"
  7.         else echo -e "Checking the  account $1 has set a password      $OK"
  8.         fi
  9.         done</etc/shadow
  10. [root@butter ~]# ./secure.sh
  11. Checking the  account  root has set a password       [  OK  ]
  12. ..........
  13. ***Warning***    The account: tom has empty password! Please contact your administrator!
  14. ........
  15. [root@butter ~]# cat /etc/shadow|grep tom
  16. tom::15708:0:99999:7:::
復(fù)制代碼

論壇徽章:
5
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亞洲杯之朝鮮
日期:2015-03-13 22:47:33IT運維版塊每日發(fā)帖之星
日期:2016-01-09 06:20:00IT運維版塊每周發(fā)帖之星
日期:2016-03-07 16:27:44
2 [報告]
發(fā)表于 2013-01-03 23:07 |只看該作者
本帖最后由 blackold 于 2013-01-03 23:08 編輯

真的很神奇,還有隱藏內(nèi)容。

論壇徽章:
2
射手座
日期:2014-10-10 15:59:4715-16賽季CBA聯(lián)賽之上海
日期:2016-03-03 10:27:14
3 [報告]
發(fā)表于 2013-01-03 23:27 |只看該作者
本帖最后由 yinyuemi 于 2013-01-03 23:28 編輯

最匪夷所思的是





























還要回復(fù)可見

論壇徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亞冠之浦和紅鉆
日期:2015-06-23 19:10:532015亞冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16賽季CBA聯(lián)賽之山東
日期:2016-01-31 18:25:0515-16賽季CBA聯(lián)賽之四川
日期:2016-02-16 16:08:30程序設(shè)計版塊每日發(fā)帖之星
日期:2016-06-29 06:20:002017金雞報曉
日期:2017-01-10 15:19:5615-16賽季CBA聯(lián)賽之佛山
日期:2017-02-27 20:41:19
4 [報告]
發(fā)表于 2013-01-04 08:49 |只看該作者
最匪夷所思的是shell也能產(chǎn)生匪夷所思的問題

論壇徽章:
3
天蝎座
日期:2013-11-11 10:18:392015年亞洲杯之沙特阿拉伯
日期:2015-04-06 15:51:08CU十四周年紀(jì)念徽章
日期:2017-01-07 22:56:29
5 [報告]
發(fā)表于 2013-01-04 09:04 |只看該作者
回復(fù) 1# wwr


  是不是發(fā)現(xiàn)了什么bug ?

論壇徽章:
5
技術(shù)圖書徽章
日期:2014-04-18 08:52:38午馬
日期:2014-04-30 13:28:11摩羯座
日期:2014-11-07 13:34:122015年亞洲杯之日本
日期:2015-03-12 14:01:4915-16賽季CBA聯(lián)賽之北京
日期:2017-06-28 17:25:56
6 [報告]
發(fā)表于 2013-01-04 09:26 |只看該作者
回復(fù)可見什么情況

論壇徽章:
60
20周年集字徽章-20	
日期:2020-10-28 14:04:3015-16賽季CBA聯(lián)賽之北京
日期:2016-07-06 15:42:0715-16賽季CBA聯(lián)賽之同曦
日期:2016-06-12 10:38:0915-16賽季CBA聯(lián)賽之佛山
日期:2016-05-27 11:54:56黃金圣斗士
日期:2015-12-02 11:44:35白銀圣斗士
日期:2015-11-25 14:32:43白銀圣斗士
日期:2015-11-23 12:53:352015亞冠之布里斯班獅吼
日期:2015-10-21 16:55:482015亞冠之首爾
日期:2015-09-01 16:46:052015亞冠之德黑蘭石油
日期:2015-08-31 11:39:192015亞冠之薩濟(jì)拖拉機(jī)
日期:2015-08-28 21:06:5315-16賽季CBA聯(lián)賽之廣東
日期:2016-07-12 14:58:53
7 [報告]
發(fā)表于 2013-01-04 10:07 |只看該作者
第一次在shell板塊看到有隱藏內(nèi)容的 果然很神奇

論壇徽章:
2
水瓶座
日期:2014-08-20 14:38:50辰龍
日期:2014-09-15 15:49:06
8 [報告]
發(fā)表于 2013-01-04 10:27 |只看該作者
我想看看下面是怎么回復(fù)的

論壇徽章:
11
CU十二周年紀(jì)念徽章
日期:2013-10-24 15:41:342015年辭舊歲徽章
日期:2015-03-03 16:54:15丑牛
日期:2015-01-14 10:36:40技術(shù)圖書徽章
日期:2015-01-12 15:46:11白羊座
日期:2014-11-14 09:35:36獅子座
日期:2014-10-30 13:18:49巳蛇
日期:2014-10-11 12:52:08子鼠
日期:2014-09-28 14:11:06雙魚座
日期:2014-04-22 13:05:48午馬
日期:2014-02-11 17:58:002015年迎新春徽章
日期:2015-03-04 09:55:28
9 [報告]
發(fā)表于 2013-01-04 10:53 |只看該作者
奇怪的事情發(fā)生了。。。俺來看大牛解答!

論壇徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年紀(jì)念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役紀(jì)念章
日期:2022-04-24 14:33:24
10 [報告]
發(fā)表于 2013-01-04 11:00 |只看該作者
http://catb.org/~esr/faqs/smart-questions.html
Don't rush to claim that you have found a bug

When you are having problems with a piece of software, don't claim you have found a bug unless you are very, very sure of your ground. Hint: unless you can provide a source-code patch that fixes the problem, or a regression test against a previous version that demonstrates incorrect behavior, you are probably not sure enough. This applies to webpages and documentation, too; if you have found a documentation “bug”, you should supply replacement text and which pages it should go on.

Remember, there are many other users that are not experiencing your problem. Otherwise you would have learned about it while reading the documentation and searching the Web (you did do that before complaining, didn't you?). This means that very probably it is you who are doing something wrong, not the software.

The people who wrote the software work very hard to make it work as well as possible. If you claim you have found a bug, you'll be impugning their competence, which may offend some of them even if you are correct. It's especially undiplomatic to yell “bug” in the Subject line.

When asking your question, it is best to write as though you assume you are doing something wrong, even if you are privately pretty sure you have found an actual bug. If there really is a bug, you will hear about it in the answer. Play it so the maintainers will want to apologize to you if the bug is real, rather than so that you will owe them an apology if you have messed up.

@aqbssh
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP